From 7acf8ce6111e3740decd39b92c3383fcbdd00e21 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Mar 2018 14:34:12 +0200 Subject: Implement fetch command --- bdep/fetch.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bdep/fetch.cxx (limited to 'bdep/fetch.cxx') diff --git a/bdep/fetch.cxx b/bdep/fetch.cxx new file mode 100644 index 0000000..6231d8b --- /dev/null +++ b/bdep/fetch.cxx @@ -0,0 +1,59 @@ +// file : bdep/fetch.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include + +using namespace std; + +namespace bdep +{ + int + cmd_fetch (const cmd_fetch_options& o, cli::scanner&) + { + tracer trace ("fetch"); + + dir_path prj ( + find_project_packages (o, true /* ignore_packages */).project); + + database db (open (prj, trace)); + + transaction t (db.begin ()); + configurations cfgs (find_configurations (prj, t, o)); + t.commit (); + + bool first (true); + for (const shared_ptr& c: cfgs) + { + if (c->packages.empty ()) + { + info << "no packages initialized in configuration " << *c; + continue; + } + + // If we are fetching in multiple configurations, separate them with a + // blank line and print the configuration name/directory. + // + if (verb && cfgs.size () > 1) + { + text << (first ? "" : "\n") + << "fetching in configuration " << *c; + + first = false; + } + + // Let's use the repository name rather than the location as a sanity + // check (the repository must have been added as part of init). + // + run_bpkg (o, + "fetch", + "-d", c->path, + (o.full () ? nullptr : ("dir:" + prj.string ()).c_str ())); + } + + return 0; + } +} -- cgit v1.1