From f02e85435d2b2bebc1fad6ef4b65227011fdcc0a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Mar 2018 12:41:32 +0200 Subject: Switch to CLI-generated group_scanner --- bpkg/bpkg.cxx | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'bpkg/bpkg.cxx') 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 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 (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); -- cgit v1.1