22 bool required =
false;
30 "Print help message including a list of all available methods.")(
33 po::value<std::vector<std::string> >(&
m_desc_vec)
37 "Print extended usage description. "
38 "Use '--desc [MethodName [MethodName2...]]' for detailed method "
39 "descriptions. Partial matches of method names are acceptable.")(
43 "Method to use: Can use method name (including partial matches) or "
58 m_info_method_vector(nullptr) {}
61 if (
vm().
count(
"method") != 1) {
62 err_log() <<
"Error in 'casm info'. The --method option is required."
68 err_log() <<
"Error in 'casm info'. The options --settings or --input may "
81 log() <<
"\nFor complete options description, use 'casm info --desc "
88 if (
opt().desc_vec().size()) {
92 for (
const auto &in_name :
opt().desc_vec()) {
94 if (interface_ptr->name().substr(0, in_name.size()) == in_name) {
95 log() << interface_ptr->desc() << std::endl;
103 log() <<
"No match found. ";
112 log() <<
"DESCRIPTION\n" << std::endl;
114 log() <<
" casm info --settings input.json \n"
115 " casm info --input '{...JSON...}' \n"
116 " - Input settings in JSON format. \n\n";
120 log() <<
"\nFor complete options help for a particular method, \n"
121 "use 'casm info --desc MethodName'.\n\n";
141 auto method_name_matches =
143 return interface_ptr->name().substr(0,
opt().
method().size()) ==
147 method_name_matches);
149 PrimClex const *primclex_ptr =
nullptr;
156 method_name_matches);
157 (*it)->run(json_options, primclex_ptr);
160 }
else if (
count < 1) {
162 int method_index = -1;
164 method_index = stoi(
opt().method());
172 if (method_index < 0 || method_index >=
info_methods().size()) {
180 std::advance(it, method_index);
182 (*it)->run(json_options, primclex_ptr);
184 }
else if (
count > 1) {
190 throw std::runtime_error(
"Unknown error in InfoCommand::run");
205 sout <<
"The `casm info` methods are:\n";
208 sout <<
" " << counter <<
") " << interface_ptr->name() << std::endl;
const CommandArgs & args() const
PrimClex & primclex() const
const OptionType & opt() const
const po::variables_map & vm() const
int count(std::string s) const
static std::string infomethod()
Get value_type string for infomethod mode completion.
void initialize() override
Fill in the options descriptions accordingly.
std::string method() const
std::vector< std::string > m_desc_vec
void add_input_suboption(bool required=true)
const po::options_description & desc()
Get the program options, filled with the initialized values.
void add_settings_suboption(bool required=true)
po::options_description m_desc
int help() const override
InfoInterfaceVector m_standard_info_methods
int vm_count_check() const override
static const std::string name
InfoInterfaceVector const & info_methods() const
int desc() const override
InfoCommand(const CommandArgs &_args, Completer::InfoOption &_opt)
InfoInterfaceVector const * m_info_method_vector
void print_names(std::ostream &sout, InfoInterfaceVector const &info_methods) const
PrimClex is the top-level data structure for a CASM project.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
InfoInterfaceVector make_standard_info_method_interfaces()
A vector containing casm info method interfaces.
std::vector< notstd::cloneable_ptr< InfoInterfaceBase > > InfoInterfaceVector
jsonParser make_json_input(const OptionType &opt)
Data structure holding basic CASM command info.