CASM  1.1.0
A Clusters Approach to Statistical Mechanics
EnumInterface.cc
Go to the documentation of this file.
1 
3 
8 
9 namespace CASM {
10 
31  const auto &vm = enum_opt.vm();
32 
33  json.put_obj();
34  if (vm.count("desc")) {
35  json["desc"] = enum_opt.desc_vec(); // vector<std::string>
36  }
37  if (vm.count("help")) {
38  json["help"] = static_cast<bool>(vm.count("help")); // bool
39  }
40  if (vm.count("method")) {
41  json["method"] = enum_opt.method(); // str
42  }
43  if (vm.count("settings")) {
44  json["settings"] = enum_opt.settings_path().string(); // str
45  }
46  if (vm.count("input")) {
47  json["input"] = enum_opt.input_str(); // str
48  }
49 
50  if (vm.count("min")) {
51  json["min"] = enum_opt.min_volume(); // int
52  }
53  if (vm.count("max")) {
54  json["max"] = enum_opt.max_volume(); // int
55  }
56  if (vm.count("filter")) {
57  json["filter"] = enum_opt.filter_str(); // std::string
58  }
59  if (vm.count("all") && !vm["all"].defaulted()) {
60  json["all"] = enum_opt.all_existing(); // bool
61  }
62  if (vm.count("verbosity") && !vm["verbosity"].defaulted()) {
63  json["verbosity"] = enum_opt.verbosity_str(); // str
64  }
65  if (vm.count("scelnames")) {
66  json["scelnames"] = enum_opt.supercell_strs(); // vector<std::string>
67  }
68  if (vm.count("confignames")) {
69  json["confignames"] = enum_opt.config_strs(); // vector<std::string>
70  }
71  if (vm.count("dry-run")) {
72  json["dry_run"] = enum_opt.dry_run(); // bool
73  }
74  return json;
75 }
76 
79  Log &log, jsonParser const &json_options,
80  jsonParser const &cli_options_as_json) {
81  log.indent() << "Input from JSON (--input or --setings):\n"
82  << json_options << std::endl
83  << std::endl;
84  log.indent() << "Input from `casm enum` options:\n"
85  << cli_options_as_json << std::endl
86  << std::endl;
87 
88  // combine JSON options and CLI options
90  json_options, cli_options_as_json);
91 
92  log.indent() << "Combined Input:\n"
93  << json_combined << std::endl
94  << std::endl;
95  return ParentInputParser{json_combined};
96 }
97 
98 } // namespace CASM
const std::vector< std::string > & config_strs() const
Definition: Handlers.cc:382
std::string input_str() const
Returns the path corresponding to add_input_suboption.
Definition: Handlers.cc:368
const std::vector< std::string > & supercell_strs() const
Returns the list of the supercells for add_scelnames_suboption()
Definition: Handlers.cc:390
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
Definition: Handlers.cc:364
const std::vector< std::string > & desc_vec() const
Definition: Handlers.hh:886
std::string method() const
Definition: Handlers.hh:888
const std::string & filter_str() const
Definition: Handlers.hh:890
const std::string & verbosity_str() const
Returns the string corresponding to add_verbosity_suboption()
Definition: Handlers.cc:350
po::variables_map & vm()
Get the variables map.
Definition: Handlers.cc:310
Definition: Log.hh:48
Log & indent()
Definition: Log.hh:289
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:354
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
Log & log()
Definition: Log.hh:424
ParentInputParser make_enum_parent_parser(Log &log, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Combine –input / –settings JSON with CLI options.
jsonParser combine_configuration_enum_json_options(jsonParser const &json_options, jsonParser const &cli_options_as_json)