Browse Source

Flag to read stdin for `catalog import`

default_compile_flags
vector-of-bool 4 years ago
parent
commit
6ae7eeb23f
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      src/dds.main.cpp

+ 8
- 0
src/dds.main.cpp View File



#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include <sstream>


namespace { namespace {


common_flags _common{cmd}; common_flags _common{cmd};


catalog_path_flag cat_path{cmd}; catalog_path_flag cat_path{cmd};

args::Flag import_stdin{cmd, "stdin", "Import JSON from stdin", {"stdin"}};
args::ValueFlagList<std::string> args::ValueFlagList<std::string>
json_paths{cmd, json_paths{cmd,
"json", "json",
for (const auto& json_fpath : json_paths.Get()) { for (const auto& json_fpath : json_paths.Get()) {
cat.import_json_file(json_fpath); cat.import_json_file(json_fpath);
} }
if (import_stdin.Get()) {
std::ostringstream strm;
strm << std::cin.rdbuf();
cat.import_json_str(strm.str());
}
return 0; return 0;
} }
} import{*this}; } import{*this};

Loading…
Cancel
Save