diff options
-rw-r--r-- | bpkg/bpkg.cxx | 33 | ||||
-rw-r--r-- | bpkg/buildfile | 5 | ||||
-rw-r--r-- | bpkg/types-parsers.cxx | 2 | ||||
-rw-r--r-- | bpkg/types-parsers.hxx | 7 |
4 files changed, 30 insertions, 17 deletions
diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx index ba9fe95..ece9046 100644 --- a/bpkg/bpkg.cxx +++ b/bpkg/bpkg.cxx @@ -67,7 +67,10 @@ cfg_dir (...) -> const dir_path& {return empty_dir_path;} // template <typename O> static O -init (const common_options& co, cli::scanner& scan, strings& args, bool tmp) +init (const common_options& co, + cli::group_scanner& scan, + strings& args, + bool tmp) { O o; static_cast<common_options&> (o) = co; @@ -90,15 +93,27 @@ init (const common_options& co, cli::scanner& scan, strings& args, bool tmp) // Parse the next chunk of options until we reach an argument (or eos). // - o.parse (scan); - - if (!scan.more ()) - break; + if (o.parse (scan)) + continue; // Fall through. } - args.push_back (scan.next ()); + // Copy over the argument including the group. + // + using scanner = cli::scanner; + using group_scanner = cli::group_scanner; + + args.push_back (group_scanner::escape (scan.next ())); + + scanner& gscan (scan.group ()); + if (gscan.more ()) + { + args.push_back ("+{"); + while (gscan.more ()) + args.push_back (group_scanner::escape (gscan.next ())); + args.push_back ("}"); + } } // Global initializations. @@ -161,7 +176,8 @@ try << system_error (errno, generic_category ()); // Sanitize. #endif - argv_file_scanner scan (argc, argv, "--options-file"); + argv_file_scanner argv_scan (argc, argv, "--options-file"); + group_scanner scan (argv_scan); // First parse common options and --version/--help. // @@ -179,7 +195,8 @@ try } strings argsv; // To be filled by parse() above. - vector_scanner args (argsv); + vector_scanner vect_args (argsv); + group_scanner args (vect_args); const common_options& co (o); diff --git a/bpkg/buildfile b/bpkg/buildfile index f25e08e..4c4c715 100644 --- a/bpkg/buildfile +++ b/bpkg/buildfile @@ -113,8 +113,9 @@ if $cli.configured cli.options += -I $src_root --include-with-brackets --include-prefix bpkg \ --guard-prefix BPKG --cxx-prologue "#include <bpkg/types-parsers.hxx>" \ --cli-namespace bpkg::cli --generate-vector-scanner --generate-file-scanner \ ---generate-specifier --generate-parse --page-usage 'bpkg::print_$name$_' \ ---ansi-color --include-base-last --option-length 23 +--generate-group-scanner --keep-separator --generate-specifier \ +--generate-parse --page-usage 'bpkg::print_$name$_' --ansi-color \ +--include-base-last --option-length 23 cli.cxx{common-options}: cli.options += --short-usage --long-usage # Both. cli.cxx{bpkg-options}: cli.options += --short-usage --suppress-undocumented diff --git a/bpkg/types-parsers.cxx b/bpkg/types-parsers.cxx index 41b231f..b414bb3 100644 --- a/bpkg/types-parsers.cxx +++ b/bpkg/types-parsers.cxx @@ -4,8 +4,6 @@ #include <bpkg/types-parsers.hxx> -#include <bpkg/common-options.hxx> // bpkg::cli namespace - namespace bpkg { namespace cli diff --git a/bpkg/types-parsers.hxx b/bpkg/types-parsers.hxx index 4f1dfc7..349eaae 100644 --- a/bpkg/types-parsers.hxx +++ b/bpkg/types-parsers.hxx @@ -11,17 +11,14 @@ #include <libbpkg/manifest.hxx> #include <bpkg/types.hxx> + +#include <bpkg/common-options.hxx> // bpkg::cli namespace #include <bpkg/options-types.hxx> namespace bpkg { namespace cli { - class scanner; - - template <typename T> - struct parser; - template <> struct parser<path> { |