diff options
Diffstat (limited to 'bpkg/cfg-info.cxx')
-rw-r--r-- | bpkg/cfg-info.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bpkg/cfg-info.cxx b/bpkg/cfg-info.cxx new file mode 100644 index 0000000..39008eb --- /dev/null +++ b/bpkg/cfg-info.cxx @@ -0,0 +1,41 @@ +// file : bpkg/cfg-info.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include <bpkg/cfg-info.hxx> + +#include <iostream> // cout + +#include <bpkg/database.hxx> +#include <bpkg/diagnostics.hxx> + +using namespace std; + +namespace bpkg +{ + int + cfg_info (const cfg_info_options& o, cli::scanner&) + { + tracer trace ("cfg_info"); + + dir_path c (o.directory ()); + l4 ([&]{trace << "configuration: " << c;}); + + database db (c, trace, false /* pre_attach */); + + try + { + cout.exceptions (ostream::badbit | ostream::failbit); + + cout << "path: " << db.config << endl + << "uuid: " << db.uuid << endl + << "type: " << db.type << endl + << "name: " << (db.name ? *db.name : "") << endl; + } + catch (const io_error&) + { + fail << "unable to write to stdout"; + } + + return 0; + } +} |