From 61cdde35094fc655eac2e6968b465f217e91d0ac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 14 May 2018 16:06:18 +0200 Subject: Add --wipe option to configuration creating commands --- bdep/config.cxx | 13 +++++++++++-- bdep/init.cxx | 3 +++ bdep/new.cxx | 3 +++ bdep/project.cli | 6 ++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bdep/config.cxx b/bdep/config.cxx index 28289fb..70441cc 100644 --- a/bdep/config.cxx +++ b/bdep/config.cxx @@ -174,7 +174,12 @@ namespace bdep while (cfg_args.more ()) args.push_back (cfg_args.next ()); - run_bpkg (2, co, "create", "-d", path, args); + run_bpkg (2, + co, + "create", + "-d", path, + (ao.wipe () ? "--wipe" : nullptr), + args); } return cmd_config_add (ao, @@ -233,7 +238,8 @@ namespace bdep o.forward () ? "--forward" : o.no_forward () ? "--no-forward" : o.auto_sync () ? "--auto-sync" : - o.no_auto_sync () ? "--no-auto-sync" : nullptr); + o.no_auto_sync () ? "--no-auto-sync" : + o.wipe () ? "--wipe" : nullptr); } int @@ -252,6 +258,9 @@ namespace bdep { if (!(c.add () || c.create () || c.set ())) fail << n << " not valid for this command"; + + if (o.wipe () && !c.create ()) + fail << "--wipe is not valid for this command"; } // --all diff --git a/bdep/init.cxx b/bdep/init.cxx index 9fe4334..1ea55e9 100644 --- a/bdep/init.cxx +++ b/bdep/init.cxx @@ -148,6 +148,9 @@ namespace bdep { if (!ca && !cc) fail << n << " specified without --config-(add|create)"; + + if (o.wipe () && !cc) + fail << "--wipe specified without --config-create"; } project_packages pp ( diff --git a/bdep/new.cxx b/bdep/new.cxx index b04aba3..7b579fa 100644 --- a/bdep/new.cxx +++ b/bdep/new.cxx @@ -44,6 +44,9 @@ namespace bdep { if (!ca && !cc) fail << n << " specified without --config-(add|create)"; + + if (o.wipe () && !cc) + fail << "--wipe specified without --config-create"; } // Validate type options. diff --git a/bdep/project.cli b/bdep/project.cli index e62daf2..0053c19 100644 --- a/bdep/project.cli +++ b/bdep/project.cli @@ -42,6 +42,12 @@ namespace bdep "Don't make the added or created configuration automatically synchronized." } + + bool --wipe + { + "Wipe the configuration directory clean before creating the new + configuration." + } }; // Common options for commands that accept --config-id and @. -- cgit v1.1