16 bool required =
false;
19 (
"help,h",
"Print help message.")
21 po::value<std::vector<std::string> >(&
m_desc_vec)->multitoken()->zero_tokens(),
22 "Print extended usage description. "
23 "Use '--desc MethodName [MethodName2...]' for detailed option description. "
24 "Partial matches of method names will be included.")
25 (
"method,m", po::value<std::string>(&
m_method),
"Method to use: Can use number shortcuts in this option.")
26 (
"min", po::value<int>(&
m_min_volume)->default_value(1),
"Min volume")
30 "Filter configuration enumeration so that only configurations matching a "
31 "'casm query'-type expression are recorded")
34 "Enumerate configurations for all existing supercells");
57 std::unique_ptr<PrimClex> uniq_primclex;
60 po::variables_map &vm = enum_opt.
vm();
64 po::store(po::parse_command_line(args.
argc, args.
argv, enum_opt.
desc()), vm);
66 if(!vm.count(
"help") && !vm.count(
"desc")) {
74 if(vm.count(
"method") != 1) {
75 args.
err_log <<
"Error in 'casm enum'. The --method option is required." << std::endl;
79 if(vm.count(
"settings") + vm.count(
"input") == 2) {
80 args.
err_log <<
"Error in 'casm enum'. The options --settings or --input may not both be chosen." << std::endl;
92 if(vm.count(
"help")) {
94 args.
log << enum_opt.
desc() << std::endl;
97 args.
log <<
"The enumeration methods are:\n\n";
100 for(
const auto &e : *enumerators) {
101 args.
log <<
" " << counter <<
") " << e.name() << std::endl;
106 args.
log <<
"\nFor complete options description, use 'casm enum --desc MethodName'.\n\n";
114 if(vm.count(
"desc") && enum_opt.
desc_vec().size()) {
118 for(
const auto &in_name : enum_opt.
desc_vec()) {
119 for(
const auto &e : *enumerators) {
120 if(e.name().substr(0, in_name.size()) == in_name) {
121 args.
log << e.help() << std::endl;
130 args.
log <<
"No match found. The enumeration methods are:\n\n";
133 for(
const auto &e : *enumerators) {
134 args.
log <<
" " << counter <<
") " << e.name() << std::endl;
143 if(vm.count(
"desc")) {
145 args.
log << enum_opt.
desc() << std::endl;
147 args.
log <<
"DESCRIPTION\n" << std::endl;
149 args.
log <<
" casm enum --settings input.json \n"
150 " casm enum --input '{...JSON...}' \n"
151 " - Input settings in JSON format to run an enumeration. The expected \n"
155 " \"MethodName\": {\n"
156 " \"option1\" : ...,\n"
157 " \"option2\" : ...,\n"
164 args.
log <<
"The enumeration methods are:\n\n";
167 for(
const auto &e : *enumerators) {
168 args.
log <<
" " << counter <<
") " << e.name() << std::endl;
173 args.
log <<
"\nFor complete options help for a particular method, \n"
174 "use 'casm enum --desc MethodName'.\n\n";
176 args.
log <<
"Custom enumerator plugins can be added by placing source code \n"
177 "in the CASM project directory: \n"
184 catch(po::error &e) {
186 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
189 catch(std::exception &e) {
191 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
196 if(vm.count(
"settings")) {
199 else if(vm.count(
"input")) {
204 return e.name().substr(0, enum_opt.
method().size()) == enum_opt.
method();
206 int count = std::count_if(enumerators->
begin(), enumerators->
end(), lambda);
209 auto it = std::find_if(enumerators->
begin(), enumerators->
end(), lambda);
211 return it->run(*primclex, input, enum_opt);
216 int m = stoi(enum_opt.
method());
217 if(m < std::distance(enumerators->
begin(), enumerators->
end()) &&
219 auto it = enumerators->
begin();
220 for(
int k = 0; k < m; ++k) {
223 return it->run(*primclex, input, enum_opt);
227 args.
log <<
"No match found. The enumeration methods are:\n\n";
230 for(
const auto &e : *enumerators) {
231 args.
log <<
" " << counter <<
") " << e.name() << std::endl;
238 args.
err_log <<
"Multiple matches found for --method " << std::endl;
241 throw std::runtime_error(
"Unknown error in EnumCommand::run");
Data structure holding basic CASM command info.
void add_verbosity_suboption()
Add a –verbosity suboption. Default "standard" of "none", "quiet", "standard", "verbose", "debug" or an int 0-100.
int enum_command(const CommandArgs &args)
void add_scelnames_suboption()
Add a –scelnames suboption.
const DirectoryStructure & dir() const
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
void add_settings_suboption(bool required=true)
Add a –settings suboption. Expects a corresponding casm format to go with it.
Base class for generic use of enumerators that may be accessed through the API.
std::string method() const
void initialize() override
Fill in the options descriptions accordingly.
fs::path enumerator_plugins() const
Return enumerators plugin dir.
void add_input_suboption(bool required=true)
Add a –input suboption. Expects a corresponding casm format to go with it.
EnumeratorHandler & enumerator_handler()
std::string input_str() const
Returns the path corresponding to add_input_suboption.
const po::options_description & desc()
Get the program options, filled with the initialized values.
std::vector< std::string > m_desc_vec
static std::string query()
Get value_type string for query completion.
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
ProjectSettings & settings()
const std::vector< std::string > & desc_vec() const
PrimClex is the top-level data structure for a CASM project.
void add_confignames_suboption()
Add a –confignames suboption.
po::variables_map & vm()
Get the variables map.
PrimClex & make_primclex_if_not(const CommandArgs &args, std::unique_ptr< PrimClex > &uniq_primclex)
If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or c...
static jsonParser parse(const std::string &str)
Construct a jsonParser from a string containing JSON data.
std::map wrapper to enforce a 1-1 ValueType->KeyType relationship
void error(const std::string &what)
std::vector< std::string > m_filter_strs