From fd68f4dd2036c106f047793a1e5656b1ade6fd9d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Oct 2015 08:23:22 +0200 Subject: Add drop command skeleton --- bpkg/bpkg-options.cli | 7 +++++++ bpkg/bpkg.cxx | 2 ++ bpkg/buildfile | 2 ++ bpkg/drop | 17 +++++++++++++++++ bpkg/drop-options.cli | 48 +++++++++++++++++++++++++++++++++++++++++++++++ bpkg/drop.cxx | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 bpkg/drop create mode 100644 bpkg/drop-options.cli create mode 100644 bpkg/drop.cxx diff --git a/bpkg/bpkg-options.cli b/bpkg/bpkg-options.cli index 156bf99..176eafd 100644 --- a/bpkg/bpkg-options.cli +++ b/bpkg/bpkg-options.cli @@ -28,6 +28,13 @@ namespace bpkg "" }; + bool drop + { + "...", + "Drop one or more packages.", + "" + }; + bool pkg-verify { "", diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx index 51c3b0a..61f7425 100644 --- a/bpkg/bpkg.cxx +++ b/bpkg/bpkg.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -183,6 +184,7 @@ try #define COMMAND(CMD) COMMAND_IMPL(, "", CMD) COMMAND(build); + COMMAND(drop); // pkg-* commands // diff --git a/bpkg/buildfile b/bpkg/buildfile index 12bb391..e01dc92 100644 --- a/bpkg/buildfile +++ b/bpkg/buildfile @@ -16,6 +16,7 @@ exe{bpkg}: cxx{satisfaction fetch package package-odb manifest-utility \ cxx{help} cli.cxx{help-options} \ cli.cxx{configuration-options} \ cxx{build} cli.cxx{build-options} \ + cxx{drop} cli.cxx{drop-options} \ cxx{pkg-command} \ cxx{pkg-verify} cli.cxx{pkg-verify-options} \ cxx{pkg-status} cli.cxx{pkg-status-options} \ @@ -55,6 +56,7 @@ cli.cxx{configuration-options}: cli.options += --exclude-base # # cli.cxx{build-options}: cli{build-options} +cli.cxx{drop-options}: cli{drop-options} # pkg-* # diff --git a/bpkg/drop b/bpkg/drop new file mode 100644 index 0000000..1687c82 --- /dev/null +++ b/bpkg/drop @@ -0,0 +1,17 @@ +// file : bpkg/drop -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BPKG_DROP +#define BPKG_DROP + +#include +#include + +namespace bpkg +{ + void + drop (const drop_options&, cli::scanner& args); +} + +#endif // BPKG_DROP diff --git a/bpkg/drop-options.cli b/bpkg/drop-options.cli new file mode 100644 index 0000000..301bc9a --- /dev/null +++ b/bpkg/drop-options.cli @@ -0,0 +1,48 @@ +// file : bpkg/drop-options.cli +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +include ; + +/* +"\section=1" +"\name=bpkg-drop" + +"\h{SYNOPSIS} + +bpkg drop [] ..." + +"\h{DESCRIPTION} + +The \cb{drop} command drops one or more packages from the configuration. +If the packages being dropped still have dependents, then those will have +to be drop as well and you will be prompted for a confirmation. Similarly, +if the packages being dropped have prerequisites that are no longer needed, +you will be offered to drop those as well. + +The \cb{drop} command also supports several \cb{--*-only} options that allow +you to limit the amount of work that will be done. +*/ + +namespace bpkg +{ + class drop_options: configuration_options + { + bool --yes|-y + { + "Assume the answer to all prompts is \cb{yes}. Note that this option + does not apply to the dropping of dependents confirmation." + }; + + bool --disfigure-only|-d + { + "Disfigure all the packages but don't purge." + }; + + bool --print-only|-p + { + "Print to \cb{STDOUT} what would be done without actually doing + anything." + }; + }; +} diff --git a/bpkg/drop.cxx b/bpkg/drop.cxx new file mode 100644 index 0000000..ac3919e --- /dev/null +++ b/bpkg/drop.cxx @@ -0,0 +1,52 @@ +// file : bpkg/drop.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include // cout + +#include // reverse_iterate() + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace std; +using namespace butl; + +namespace bpkg +{ + void + drop (const drop_options& o, cli::scanner& args) + { + tracer trace ("drop"); + + const dir_path& c (o.directory ()); + level4 ([&]{trace << "configuration: " << c;}); + + if (!args.more ()) + fail << "package name argument expected" << + info << "run 'bpkg help drop' for more information"; + + database db (open (c, trace)); + + // Note that the session spans all our transactions. The idea here is + // that selected_package objects in the satisfied_packages list below + // will be cached in this session. When subsequent transactions modify + // any of these objects, they will modify the cached instance, which + // means our list will always "see" their updated state. + // + session s; + } +} -- cgit v1.1