diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-07 15:59:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-07 15:59:37 +0200 |
commit | b1078fdb9fac747c19dbdacd24c2838aae7d9f6b (patch) | |
tree | 3452bab97d91b063ac3cac2cb3d84ae184c21858 /bpkg/types-parsers.cxx | |
parent | 8f94aaa067426a259f5396abdaf4945671799b5c (diff) |
Implement cfg-create command
Diffstat (limited to 'bpkg/types-parsers.cxx')
-rw-r--r-- | bpkg/types-parsers.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bpkg/types-parsers.cxx b/bpkg/types-parsers.cxx new file mode 100644 index 0000000..544908c --- /dev/null +++ b/bpkg/types-parsers.cxx @@ -0,0 +1,37 @@ +// file : bpkg/types-parsers.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <bpkg/types-parsers> + +#include <bpkg/common-options> // bpkg::cli namespace + +namespace bpkg +{ + namespace cli + { + void parser<dir_path>:: + parse (dir_path& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const char* v (s.next ()); + + try + { + x = dir_path (v); + + if (x.empty ()) + throw invalid_value (o, v); + } + catch (const invalid_path&) + { + throw invalid_value (o, v); + } + } + } +} |