aboutsummaryrefslogtreecommitdiff
path: root/bdep/config.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/config.cxx
parent14196b5836b01a48044d73b09dff96da3a97751b (diff)
Setup config subcommand handling infrastructure
Diffstat (limited to 'bdep/config.cxx')
-rw-r--r--bdep/config.cxx72
1 files changed, 64 insertions, 8 deletions
diff --git a/bdep/config.cxx b/bdep/config.cxx
index 55a1062..0acd227 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -100,6 +100,12 @@ namespace bdep
return r;
}
+ static int
+ cmd_config_add (const cmd_config_options&, cli::scanner&)
+ {
+ fail << "@@ TODO" << endf;
+ }
+
shared_ptr<configuration>
cmd_config_create (const common_options& co,
const dir_path& prj,
@@ -129,22 +135,72 @@ namespace bdep
"created");
}
- int
- cmd_config (const cmd_config_options& o, cli::scanner&)
+ static int
+ cmd_config_create (const cmd_config_options&, cli::scanner&)
+ {
+ fail << "@@ TODO" << endf;
+ }
+
+ static int
+ cmd_config_remove (const cmd_config_options&, cli::scanner&)
+ {
+ fail << "@@ TODO" << endf;
+ }
+
+ static int
+ cmd_config_rename (const cmd_config_options&, cli::scanner&)
+ {
+ fail << "@@ TODO" << endf;
+ }
+
+ static int
+ cmd_config_set (const cmd_config_options&, cli::scanner&)
{
- //@@ TODO: get subcommand and pass to tracer.
- //@@ TODO: define a CLI options class for subcommands?
+ fail << "@@ TODO" << endf;
+ }
+ int
+ cmd_config (const cmd_config_options& o, cli::scanner& scan)
+ {
tracer trace ("config");
- //@@ TODO: validate project/config options for subcommands.
+ cmd_config_subcommands c (
+ parse_command<cmd_config_subcommands> (scan,
+ "config subcommand",
+ "bdep help config"));
+ // Validate options/subcommands.
+ //
+
+ // --[no-]default
+ //
if (o.default_ () && o.no_default ())
fail << "both --default and --no-default specified";
- for (const string& n: o.config_name ())
- text << n;
+ if (const char* n = (o.default_ () ? "--default" :
+ o.no_default () ? "--no-default" : nullptr))
+ {
+ if (!(c.add () || c.create () || c.set ()))
+ fail << n << " not valid for this command";
+ }
+
+ // --all
+ //
+ if (o.all ())
+ {
+ if (!c.remove ())
+ fail << "--all not valid for this command";
+ }
- return 0;
+ // Dispatch to subcommand function.
+ //
+ if (c.add ()) return cmd_config_add (o, scan);
+ if (c.create ()) return cmd_config_create (o, scan);
+ if (c.remove ()) return cmd_config_remove (o, scan);
+ if (c.rename ()) return cmd_config_rename (o, scan);
+ if (c.set ()) return cmd_config_set (o, scan);
+
+ assert (false); // Unhandled (new) subcommand.
+ return 1;
}
}