aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-add.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-28 08:38:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-28 08:38:40 +0200
commit749cd532f72108b26a78cd2f0012e6abd72b3ce8 (patch)
treedf9f424dba608536cf77c3d188a53df89a4b6440 /bpkg/rep-add.cxx
parentc602595c08efae5ff1b05e0b8c7d4ab430f8f033 (diff)
Factory common code for version, repository location parsing
Diffstat (limited to 'bpkg/rep-add.cxx')
-rw-r--r--bpkg/rep-add.cxx19
1 files changed, 2 insertions, 17 deletions
diff --git a/bpkg/rep-add.cxx b/bpkg/rep-add.cxx
index 924cd65..bed6b86 100644
--- a/bpkg/rep-add.cxx
+++ b/bpkg/rep-add.cxx
@@ -12,6 +12,7 @@
#include <bpkg/utility>
#include <bpkg/database>
#include <bpkg/diagnostics>
+#include <bpkg/manifest-utility>
using namespace std;
using namespace butl;
@@ -30,23 +31,7 @@ namespace bpkg
fail << "repository location argument expected" <<
info << "run 'bpkg help rep-add' for more information";
- // Figure out the repository location.
- //
- const char* arg (args.next ());
- repository_location rl;
- try
- {
- rl = repository_location (arg, repository_location ());
-
- if (rl.relative ()) // Throws if location is empty.
- rl = repository_location (
- dir_path (arg).complete ().normalize ().string ());
- }
- catch (const invalid_argument& e)
- {
- fail << "invalid repository location '" << arg << "': " << e.what ();
- }
-
+ repository_location rl (parse_location (args.next ()));
const string& rn (rl.canonical_name ());
// Create the new repository and add is as a complement to the root.