aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/commandlineoptions.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-06-04 14:03:55 +0200
committerGitHub Enterprise <[email protected]>2025-06-04 14:03:55 +0200
commitc44b9f7151a047cde5edd369f9adb09518a0bc6f (patch)
tree7daf674e363c67f492ea1f9d0527764a60f9135a /src/zenutil/commandlineoptions.cpp
parentnew builds search (#418) (diff)
downloadzen-c44b9f7151a047cde5edd369f9adb09518a0bc6f.tar.xz
zen-c44b9f7151a047cde5edd369f9adb09518a0bc6f.zip
builds download url (#419)
* RemoveQuotes helper * `--url` option for `zen builds` command has been reworked to accept a "Cloud Artifact URL", removing the need to specify "host", "namespace" and "bucket" separately
Diffstat (limited to 'src/zenutil/commandlineoptions.cpp')
-rw-r--r--src/zenutil/commandlineoptions.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/zenutil/commandlineoptions.cpp b/src/zenutil/commandlineoptions.cpp
index 0dffa42f0..afef7f6f2 100644
--- a/src/zenutil/commandlineoptions.cpp
+++ b/src/zenutil/commandlineoptions.cpp
@@ -157,12 +157,7 @@ MakeSafeAbsolutePath(const std::filesystem::path& Path)
std::filesystem::path
StringToPath(const std::string_view& Path)
{
- std::string_view UnquotedPath = Path;
-
- if (UnquotedPath.length() > 2 && UnquotedPath.front() == '\"' && UnquotedPath.back() == '\"')
- {
- UnquotedPath = UnquotedPath.substr(1, UnquotedPath.length() - 2);
- }
+ std::string_view UnquotedPath = RemoveQuotes(Path);
if (UnquotedPath.ends_with('/') || UnquotedPath.ends_with('\\') || UnquotedPath.ends_with(std::filesystem::path::preferred_separator))
{
@@ -172,6 +167,19 @@ StringToPath(const std::string_view& Path)
return std::filesystem::path(UnquotedPath).make_preferred();
}
+std::string_view
+RemoveQuotes(const std::string_view& Arg)
+{
+ if (Arg.length() > 2)
+ {
+ if (Arg[0] == '"' && Arg[Arg.length() - 1] == '"')
+ {
+ return Arg.substr(1, Arg.length() - 2);
+ }
+ }
+ return Arg;
+}
+
#if ZEN_WITH_TESTS
void