From b1078fdb9fac747c19dbdacd24c2838aae7d9f6b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Sep 2015 15:59:37 +0200 Subject: Implement cfg-create command --- bpkg/types-parsers.cxx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bpkg/types-parsers.cxx (limited to 'bpkg/types-parsers.cxx') 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 + +#include // bpkg::cli namespace + +namespace bpkg +{ + namespace cli + { + void parser:: + 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); + } + } + } +} -- cgit v1.1