aboutsummaryrefslogtreecommitdiff
path: root/bdep/bdep.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-29 16:25:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-03-29 16:25:36 +0200
commitc4d8116334a3fb235f729566b1095112aa2ac9cb (patch)
treec0656696e09c3bbe07202e903fe29c9673c88cfa /bdep/bdep.cxx
parent14196b5836b01a48044d73b09dff96da3a97751b (diff)
Setup config subcommand handling infrastructure
Diffstat (limited to 'bdep/bdep.cxx')
-rw-r--r--bdep/bdep.cxx25
1 files changed, 5 insertions, 20 deletions
diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx
index 1f9c2ca..2541325 100644
--- a/bdep/bdep.cxx
+++ b/bdep/bdep.cxx
@@ -185,18 +185,7 @@ try
// The next argument should be a command.
//
- if (!scan.more ())
- fail << "bdep command expected" <<
- info << "run 'bdep help' for more information";
-
- int cmd_argc (2);
- char* cmd_argv[] {argv[0], const_cast<char*> (scan.next ())};
- commands cmd;
- cmd.parse (cmd_argc, cmd_argv, true, unknown_mode::stop);
-
- if (cmd_argc != 1)
- fail << "unknown bdep command/option '" << cmd_argv[1] << "'" <<
- info << "run 'bdep help' for more information";
+ commands cmd (parse_command<commands> (scan, "bdep command", "bdep help"));
// If the command is 'help', then what's coming next is another command.
// Parse it into cmd so that we only need to check for each command in one
@@ -211,18 +200,14 @@ try
if (args.more ())
{
- cmd_argc = 2;
- cmd_argv[1] = const_cast<char*> (args.next ());
+ const char* a (args.next ());
- // First see if this is a command.
- //
cmd = commands (); // Clear the help option.
- cmd.parse (cmd_argc, cmd_argv, true, unknown_mode::stop);
- // If not, then it got to be a help topic.
+ // If not a command, then it got to be a help topic.
//
- if (cmd_argc != 1)
- return help (ho, cmd_argv[1], nullptr);
+ if (!parse_command (a, cmd))
+ return help (ho, a, nullptr);
}
else
return help (ho, "", nullptr);