CASM  1.1.0
A Clusters Approach to Statistical Mechanics
Handlers.cc
Go to the documentation of this file.
1 #ifndef HANDLERS_CC
2 #define HANDLERS_CC
3 
5 
6 #include "casm/app/APICommand.hh"
13 #include "casm/casm_io/Log.hh"
17 #include "casm/clex/PrimClex.hh"
18 #include "casm/clex/Supercell.hh"
23 
24 namespace CASM {
25 namespace Completer {
27 
29  const po::option_description &boost_option) {
30  // This string will become something like "<path>", or "arg", or "<path>
31  // (=MASTER)"
32  std::string raw_boost_format = boost_option.format_parameter();
33  // Sometimes boost option has default arguments. We don't want to include that
34  std::string argtype_str;
35  std::string::size_type space_pos = raw_boost_format.find(' ');
36 
37  // Spaces found, probably printing default value as well. Strip it off.
38  if (space_pos != std::string::npos) {
39  argtype_str = raw_boost_format.substr(0, space_pos);
40  }
41 
42  // No spaces found, so format_parameter already returned what we wanted
43  else {
44  argtype_str = raw_boost_format;
45  }
46 
47  for (auto it = m_argument_table.begin(); it != m_argument_table.end(); ++it) {
48  if (it->first == argtype_str) {
49  return it->second;
50  }
51  }
52 
53  return ARG_TYPE::VOID;
54 }
55 
56 std::string ArgHandler::path() { return m_argument_table[0].first; }
57 
58 std::string ArgHandler::command() { return m_argument_table[1].first; }
59 
60 std::string ArgHandler::supercell() { return m_argument_table[2].first; }
61 
62 std::string ArgHandler::query() { return m_argument_table[3].first; }
63 
64 std::string ArgHandler::operation() { return m_argument_table[4].first; }
65 
66 std::string ArgHandler::configname() { return m_argument_table[5].first; }
67 
68 std::string ArgHandler::coordtype() { return m_argument_table[6].first; }
69 
70 std::string ArgHandler::dbtype() { return m_argument_table[7].first; }
71 
72 std::string ArgHandler::enummethod() { return m_argument_table[8].first; }
73 
74 std::string ArgHandler::configtype() { return m_argument_table[9].first; }
75 
76 std::string ArgHandler::calctype() { return m_argument_table[10].first; }
77 
78 std::string ArgHandler::bset() { return m_argument_table[11].first; }
79 
80 std::string ArgHandler::clex() { return m_argument_table[12].first; }
81 
82 std::string ArgHandler::ref() { return m_argument_table[13].first; }
83 
84 std::string ArgHandler::eci() { return m_argument_table[14].first; }
85 
86 std::string ArgHandler::property() { return m_argument_table[15].first; }
87 
88 std::string ArgHandler::dof() { return m_argument_table[16].first; }
89 
90 std::string ArgHandler::infomethod() { return m_argument_table[17].first; }
91 
92 void ArgHandler::void_to_bash(std::vector<std::string> &arguments) { return; }
93 
94 void ArgHandler::path_to_bash(std::vector<std::string> &arguments) {
95  arguments.push_back("BASH_COMP_PATH");
96  return;
97 }
98 
99 void ArgHandler::command_to_bash(std::vector<std::string> &arguments) {
100  arguments.push_back("BASH_COMP_BIN");
101  return;
102 }
103 
104 void ArgHandler::scelname_to_bash(std::vector<std::string> &arguments) {
105  if (!find_casmroot(boost::filesystem::current_path()).empty()) {
106  ScopedNullLogging logging;
107  const PrimClex &pclex =
108  PrimClex(find_casmroot(boost::filesystem::current_path()));
109  for (const auto &scel : pclex.const_db<Supercell>()) {
110  arguments.push_back(scel.name());
111  }
112  }
113  return;
114 }
115 
116 void ArgHandler::configname_to_bash(std::vector<std::string> &arguments) {
117  if (!find_casmroot(boost::filesystem::current_path()).empty()) {
118  ScopedNullLogging logging;
119  const PrimClex &pclex =
120  PrimClex(find_casmroot(boost::filesystem::current_path()));
121  for (const auto &config : pclex.const_db<Configuration>()) {
122  arguments.push_back(config.name());
123  }
124  }
125  return;
126 }
127 
128 void ArgHandler::operator_to_bash(std::vector<std::string> &arguments) {
130  make_dictionary<Configuration>();
131 
132  for (auto it = dict.begin(); it != dict.cend(); ++it) {
133  if (it->type() == DatumFormatterClass::Property) {
134  arguments.push_back(it->name());
135  }
136  }
137  return;
138 }
139 
140 void ArgHandler::query_to_bash(std::vector<std::string> &arguments) {
142  make_dictionary<Configuration>();
143 
144  for (auto it = config_dict.begin(); it != config_dict.cend(); ++it) {
145  if (it->type() == DatumFormatterClass::Property) {
146  arguments.push_back("config:" + it->name());
147  }
148  }
149  DataFormatterDictionary<Supercell> scel_dict = make_dictionary<Supercell>();
150 
151  for (auto it = scel_dict.begin(); it != scel_dict.cend(); ++it) {
152  if (it->type() == DatumFormatterClass::Property) {
153  arguments.push_back("scel:" + it->name());
154  }
155  }
156 
157  return;
158 }
159 
160 void ArgHandler::dbtype_to_bash(std::vector<std::string> &arguments) {
161  for (auto &item : DB::types_short()) {
162  arguments.push_back(item);
163  }
164  return;
165 }
166 
167 void ArgHandler::enummethod_to_bash(std::vector<std::string> &arguments) {
168  auto enumerator_interfaces = make_standard_enumerator_interfaces();
169  for (auto const &e : enumerator_interfaces) {
170  arguments.push_back(e->name());
171  }
172  return;
173 }
174 
175 void ArgHandler::configtype_to_bash(std::vector<std::string> &arguments) {
176  for (auto &item : DB::config_types_short()) {
177  arguments.push_back(item);
178  }
179  return;
180 }
181 
182 void ArgHandler::calctype_to_bash(std::vector<std::string> &arguments) {
183  auto checkroot = find_casmroot(boost::filesystem::current_path());
184  if (!checkroot.empty()) {
185  const DirectoryStructure dir{checkroot};
186  for (auto &item : dir.all_calctype()) {
187  arguments.push_back(item);
188  }
189  }
190  return;
191 }
192 
193 void ArgHandler::bset_to_bash(std::vector<std::string> &arguments) {
194  auto checkroot = find_casmroot(boost::filesystem::current_path());
195  if (!checkroot.empty()) {
196  const DirectoryStructure dir{checkroot};
197  for (auto &item : dir.all_bset()) {
198  arguments.push_back(item);
199  }
200  }
201  return;
202 }
203 
204 void ArgHandler::clex_to_bash(std::vector<std::string> &arguments) {
205  auto checkroot = find_casmroot(boost::filesystem::current_path());
206  if (!checkroot.empty()) {
207  const ProjectSettings set = open_project_settings(checkroot);
208  for (auto &item : set.cluster_expansions()) {
209  arguments.push_back(item.first);
210  }
211  }
212  return;
213 }
214 
215 void ArgHandler::ref_to_bash(std::vector<std::string> &arguments) {
216  auto checkroot = find_casmroot(boost::filesystem::current_path());
217  if (!checkroot.empty()) {
218  const ProjectSettings set = open_project_settings(checkroot);
219  for (auto &item : set.dir().all_ref(set.default_clex().calctype)) {
220  arguments.push_back(item);
221  }
222  }
223  return;
224 }
225 
226 void ArgHandler::eci_to_bash(std::vector<std::string> &arguments) {
227  auto checkroot = find_casmroot(boost::filesystem::current_path());
228  if (!checkroot.empty()) {
229  const ProjectSettings set = open_project_settings(checkroot);
230  const ClexDescription d = set.default_clex();
231  for (auto &item :
232  set.dir().all_eci(d.property, d.calctype, d.ref, d.bset)) {
233  arguments.push_back(item);
234  }
235  }
236  return;
237 }
238 
239 void ArgHandler::property_to_bash(std::vector<std::string> &arguments) {
240  auto checkroot = find_casmroot(boost::filesystem::current_path());
241  if (!checkroot.empty()) {
242  const DirectoryStructure dir{checkroot};
243  for (auto &item : dir.all_property()) {
244  arguments.push_back(item);
245  }
246  }
247  return;
248 }
249 
250 void ArgHandler::dof_to_bash(std::vector<std::string> &arguments) {
251  auto checkroot = find_casmroot(boost::filesystem::current_path());
252  if (!checkroot.empty()) {
253  const DirectoryStructure dir{checkroot};
254  // for(auto &item : dir.all_property()) {
255  // arguments.push_back(item);
256  //}
257  }
258  return;
259 }
260 
261 void ArgHandler::infomethod_to_bash(std::vector<std::string> &arguments) {
262  auto info_method_interfaces = make_standard_info_method_interfaces();
263  for (auto const &e : info_method_interfaces) {
264  arguments.push_back(e->name());
265  }
266  return;
267 }
268 
275 const std::vector<std::pair<std::string, ARG_TYPE> >
277  {std::make_pair("<path>", ARG_TYPE::PATH),
278  std::make_pair("<command>", ARG_TYPE::COMMAND),
279  std::make_pair("<supercell>", ARG_TYPE::SCELNAME),
280  std::make_pair("<query>", ARG_TYPE::QUERY),
281  std::make_pair("<operation>", ARG_TYPE::OPERATOR),
282  std::make_pair("<configuration>", ARG_TYPE::CONFIGNAME),
283  std::make_pair("<type>", ARG_TYPE::COORDTYPE),
284  std::make_pair("<dbtype>", ARG_TYPE::DBTYPE),
285  std::make_pair("<enummethod>", ARG_TYPE::ENUMMETHOD),
286  std::make_pair("<configtype>", ARG_TYPE::CONFIGTYPE),
287  std::make_pair("<calctype>", ARG_TYPE::CALCTYPE),
288  std::make_pair("<bset>", ARG_TYPE::BSET),
289  std::make_pair("<clex>", ARG_TYPE::CLEX),
290  std::make_pair("<ref>", ARG_TYPE::REF),
291  std::make_pair("<eci>", ARG_TYPE::ECI),
292  std::make_pair("<property>", ARG_TYPE::PROPERTY),
293  std::make_pair("<dof>", ARG_TYPE::DOF),
294  std::make_pair("<infomethod>", ARG_TYPE::INFOMETHOD)});
295 
296 //*****************************************************************************************************//
297 
298 OptionHandlerBase::OptionHandlerBase(const std::string &init_option_tag)
299  : m_tag(init_option_tag),
300  m_desc(std::string("'casm ") + init_option_tag + std::string("' usage")),
301  m_gzip_flag(false) {}
302 
303 OptionHandlerBase::OptionHandlerBase(const std::string &init_option_tag,
304  const std::string &init_descriptor)
305  : m_tag(init_option_tag), m_desc(init_descriptor), m_gzip_flag(false) {}
306 
307 const std::string &OptionHandlerBase::tag() const { return m_tag; }
308 
310 po::variables_map &OptionHandlerBase::vm() { return m_vm; }
311 
313 const po::variables_map &OptionHandlerBase::vm() const { return m_vm; }
314 
321 const po::options_description &OptionHandlerBase::desc() {
322  if (m_desc.options().size() == 0) {
323  initialize();
324  }
325 
326  return m_desc;
327 }
328 
329 const po::options_description &OptionHandlerBase::desc() const {
330  if (m_desc.options().size() == 0) {
331  throw std::logic_error(
332  "code error: Options must be initialized by calling non-const desc()");
333  }
334 
335  return m_desc;
336 }
337 
338 const fs::path &OptionHandlerBase::selection_path() const {
339  return m_selection_path;
340 }
341 
342 const std::vector<fs::path> &OptionHandlerBase::selection_paths() const {
344 }
345 
346 const fs::path &OptionHandlerBase::file_path() const { return m_file_path; }
347 
348 const fs::path &OptionHandlerBase::prim_path() const { return m_prim_path; }
349 
350 const std::string &OptionHandlerBase::verbosity_str() const {
351  return m_verbosity_str;
352 }
353 
356  auto val = Log::verbosity_level(verbosity_str());
357  if (val.first) {
358  return val.second;
359  }
360 
361  throw std::invalid_argument(Log::invalid_verbosity_msg(verbosity_str()));
362 }
363 
364 const fs::path OptionHandlerBase::settings_path() const {
365  return m_settings_path;
366 }
367 
368 std::string OptionHandlerBase::input_str() const { return m_input_str; }
369 
370 const fs::path OptionHandlerBase::output_path() const { return m_output_path; }
371 
373 
374 const std::vector<std::string> &OptionHandlerBase::help_opt_vec() const {
375  return m_help_opt_vec;
376 }
377 
378 const std::string &OptionHandlerBase::config_str() const {
379  return m_config_str;
380 }
381 
382 const std::vector<std::string> &OptionHandlerBase::config_strs() const {
383  return m_config_strs;
384 }
385 
386 const std::string &OptionHandlerBase::supercell_str() const {
387  return m_supercell_str;
388 }
389 
390 const std::vector<std::string> &OptionHandlerBase::supercell_strs() const {
391  return m_supercell_strs;
392 }
393 
394 const std::string &OptionHandlerBase::coordtype_str() const {
395  return m_coordtype_str;
396 }
397 
399  return from_string<COORD_TYPE>(coordtype_str());
400 }
401 
403 const std::vector<std::string> &OptionHandlerBase::dof_strs() const {
404  return m_dof_strs;
405 }
406 
407 void OptionHandlerBase::add_selection_suboption(const fs::path &_default) {
408  m_desc.add_options()("selection,c",
409  po::value<fs::path>(&m_selection_path)
410  ->default_value(_default)
411  ->value_name(ArgHandler::path()),
412  (std::string("Only consider the selected objects from "
413  "the given selection file. ") +
414  singleline_help<DB::SELECTION_TYPE>())
415  .c_str());
416  return;
417 }
418 
421  m_desc.add_options()(
422  "selection,c",
423  po::value<fs::path>(&m_selection_path)->value_name(ArgHandler::path()),
424  (std::string("Only consider the selected objects from the given "
425  "selection file. ") +
426  singleline_help<DB::SELECTION_TYPE>())
427  .c_str());
428  return;
429 }
430 
431 void OptionHandlerBase::add_configlist_suboption(const fs::path &_default) {
432  m_desc.add_options()("config,c",
433  po::value<fs::path>(&m_selection_path)
434  ->default_value(_default)
435  ->value_name(ArgHandler::path()),
436  (std::string("Only consider the selected configurations "
437  "of the given selection file. ") +
438  singleline_help<DB::SELECTION_TYPE>())
439  .c_str());
440  return;
441 }
442 
443 void OptionHandlerBase::add_selections_suboption(const fs::path &_default) {
444  m_desc.add_options()("selections,c",
445  po::value<std::vector<fs::path> >(&m_selection_paths)
446  ->default_value(std::vector<fs::path>{_default})
447  ->value_name(ArgHandler::path()),
448  (std::string("Only consider the selected objects from "
449  "the given selection file. ") +
450  singleline_help<DB::SELECTION_TYPE>())
451  .c_str());
452  return;
453 }
454 
455 void OptionHandlerBase::add_configlists_suboption(const fs::path &_default) {
456  m_desc.add_options()("configs,c",
457  po::value<std::vector<fs::path> >(&m_selection_paths)
458  ->default_value(std::vector<fs::path>{_default})
459  ->value_name(ArgHandler::path()),
460  (std::string("Only consider the selected configurations "
461  "of the given selection file. ") +
462  singleline_help<DB::SELECTION_TYPE>())
463  .c_str());
464  return;
465 }
466 
468  m_desc.add_options()(
469  "config,c",
470  po::value<fs::path>(&m_selection_path)->value_name(ArgHandler::path()),
471  (std::string("Only consider the selected configurations of the given "
472  "selection file. ") +
473  standard_singleline_enum_help<DB::SELECTION_TYPE>("", "filename"))
474  .c_str());
475  return;
476 }
477 
479  m_desc.add_options()(
480  "configs,c",
481  po::value<std::vector<fs::path> >(&m_selection_paths)
482  ->value_name(ArgHandler::path()),
483  (std::string("Only consider the selected configurations of the given "
484  "selection files. ") +
485  standard_singleline_enum_help<DB::SELECTION_TYPE>("", "filename"))
486  .c_str());
487  return;
488 }
489 
490 void OptionHandlerBase::add_file_path_suboption(const fs::path &_default) {
491  m_desc.add_options()(
492  "path",
493  po::value<fs::path>(&m_file_path)
494  ->default_value(_default)
495  ->value_name(ArgHandler::path()),
496  std::string("Path to directory in which to run the command. ").c_str());
497  return;
498 }
499 
500 void OptionHandlerBase::add_prim_path_suboption(const fs::path &_default) {
501  m_desc.add_options()("prim",
502  po::value<fs::path>(&m_prim_path)
503  ->default_value(_default)
504  ->value_name(ArgHandler::path()),
505  std::string("Path to prim.json or POSCAR-like file that "
506  "defines project reference crystal. ")
507  .c_str());
508  return;
509 }
510 
512  std::string _default, std::set<std::string> _configtype_opts) {
513  if (!_configtype_opts.size()) {
515  } else {
516  m_configtype_opts = _configtype_opts;
517  }
518 
519  std::stringstream help;
520  help << "Type of configurations. "
521  << standard_singleline_help(m_configtype_opts, _default) << ".";
522 
523  m_desc.add_options()("type,t",
524  po::value<std::string>(&m_configtype)
525  ->default_value(_default)
526  ->value_name(ArgHandler::configtype()),
527  help.str().c_str());
528 }
529 
530 std::string OptionHandlerBase::configtype() const { return m_configtype; }
531 
532 std::set<std::string> OptionHandlerBase::configtype_opts() const {
533  return m_configtype_opts;
534 }
535 
537  std::string _default, std::set<std::string> _db_type_opts) {
538  if (!_db_type_opts.size()) {
540  } else {
541  m_db_type_opts = _db_type_opts;
542  }
543 
544  std::stringstream help;
545  help << "Type of database objects. "
546  << standard_singleline_help(m_db_type_opts, _default) << ".";
547 
548  m_desc.add_options()("type,t",
549  po::value<std::string>(&m_db_type)
550  ->default_value(_default)
551  ->value_name(ArgHandler::dbtype()),
552  help.str().c_str());
553 }
554 
555 std::string OptionHandlerBase::db_type() const { return m_db_type; }
556 
557 std::set<std::string> OptionHandlerBase::db_type_opts() const {
558  return m_db_type_opts;
559 }
560 
562  m_desc.add_options()("help,h", "Print help message")(
563  "desc", "Print extended usage description");
564  return;
565 }
566 
568  m_desc.add_options()(
569  "help,h",
570  po::value<std::vector<std::string> >(&m_help_opt_vec)
571  ->multitoken()
572  ->zero_tokens(),
573  "Print general help. Use '--help properties' for a list of query-able "
574  "properties or '--help operators' for a list of query operators");
575  return;
576 }
577 
579  // TODO: add ArgHandler for this
580  m_desc.add_options()(
581  "verbosity",
582  po::value<std::string>(&m_verbosity_str)->default_value("standard"),
583  "Verbosity of output. Options are 'none', 'quiet', 'standard', "
584  "'verbose', 'debug', or an integer 0-100 (0: none, 100: debug).");
585  return;
586 }
587 
589  std::string help_str =
590  "Settings input file specifying which parameters should be used. See "
591  "'casm format --" +
592  tag() + "'.";
593 
594  if (required) {
595  m_desc.add_options()("settings,s",
596  po::value<fs::path>(&m_settings_path)
597  ->required()
598  ->value_name(ArgHandler::path()),
599  help_str.c_str());
600  } else {
601  m_desc.add_options()(
602  "settings,s",
603  po::value<fs::path>(&m_settings_path)->value_name(ArgHandler::path()),
604  help_str.c_str());
605  }
606 
607  return;
608 }
609 
611  std::string help_str =
612  "String specifying input settings. See 'casm format --" + tag() + "'.";
613 
614  if (required) {
615  m_desc.add_options()("input,i",
616  po::value<std::string>(&m_input_str)->required(),
617  help_str.c_str());
618  } else {
619  m_desc.add_options()("input,i", po::value<std::string>(&m_input_str),
620  help_str.c_str());
621  }
622 
623  return;
624 }
625 
627  m_desc.add_options()(
628  "output,o",
629  po::value<fs::path>(&m_output_path)->value_name(ArgHandler::path()),
630  "Name for output file. Use STDOUT to print results without extra "
631  "messages.");
632  return;
633 }
634 
635 void OptionHandlerBase::add_output_suboption(const fs::path &_default) {
636  m_desc.add_options()("output,o",
637  po::value<fs::path>(&m_output_path)
638  ->default_value(_default)
639  ->value_name(ArgHandler::path()),
640  (std::string("Name for output file. ") +
641  "Use STDOUT to print results without extra messages."
642  "If not specified, '" +
643  _default.string() + "' will be used.")
644  .c_str());
645  return;
646 }
647 
649  m_desc.add_options()("gzip,z", po::value(&m_gzip_flag)->zero_tokens(),
650  "Write gzipped output file.");
651  return;
652 }
653 
655  std::string help_str;
656  help_str = "Single supercell name to use casm " + m_tag +
657  " with, such as 'SCEL4_2_2_1_0_0_0'";
658  m_desc.add_options()("scelname",
659  po::value<std::string>(&m_supercell_str)
660  ->value_name(ArgHandler::supercell()),
661  help_str.c_str());
662  return;
663 }
664 
666  std::string help_str;
667  help_str = "One or more supercells to use casm " + m_tag +
668  " with, such as 'SCEL4_2_2_1_0_0_0'";
669  m_desc.add_options()("scelnames",
670  po::value<std::vector<std::string> >(&m_supercell_strs)
671  ->multitoken()
672  ->value_name(ArgHandler::supercell()),
673  help_str.c_str());
674  return;
675 }
676 
678  std::string help_str;
679 
680  help_str = "Single configuration to use casm " + m_tag +
681  " with, such as 'SCEL4_2_2_1_0_0_0/3'";
682 
683  m_desc.add_options()("configname",
684  po::value<std::string>(&m_config_str)
685  ->value_name(ArgHandler::configname()),
686  help_str.c_str());
687 
688  return;
689 }
690 
692  std::string help_str;
693 
694  help_str = "One or more configurations to use casm " + m_tag +
695  " with, such as 'SCEL4_2_2_1_0_0_0/3'";
696 
697  m_desc.add_options()("confignames",
698  po::value<std::vector<std::string> >(&m_config_strs)
699  ->multitoken()
700  ->value_name(ArgHandler::configname()),
701  help_str.c_str());
702 
703  return;
704 }
705 
707  std::string help_str;
708 
709  help_str = "One or more object names to use casm " + m_tag +
710  " with, such as 'SCEL4_2_2_1_0_0_0/3'";
711 
712  m_desc.add_options()("names",
713  po::value<std::vector<std::string> >(&m_name_strs)
714  ->multitoken()
715  ->value_name(ArgHandler::configname()),
716  help_str.c_str());
717 
718  return;
719 }
720 
721 const std::vector<std::string> &OptionHandlerBase::name_strs() const {
722  return m_name_strs;
723 }
724 
726  m_desc.add_options()("coord",
727  po::value<std::string>(&m_coordtype_str)
728  ->default_value("frac")
729  ->value_name(ArgHandler::coordtype()),
730  (std::string("Type of coordinate system to use. ") +
731  singleline_help<COORD_TYPE>())
732  .c_str());
733  return;
734 }
735 
738  std::string help_str;
739  help_str = "One or more DoF types to use casm " + m_tag +
740  " with, such as 'disp' or 'EAstrain'";
741  m_desc.add_options()("dofs",
742  po::value<std::vector<std::string> >(&m_dof_strs)
743  ->multitoken()
744  ->value_name(ArgHandler::dof()),
745  help_str.c_str());
746  return;
747 }
748 
750  m_desc.add_options()("dry-run,n", msg.c_str());
751 }
752 
754  return std::string("Dry run (if supported by method)");
755 }
756 
757 bool OptionHandlerBase::dry_run() const { return vm().count("dry-run"); }
758 
759 //*****************************************************************************************************//
760 
761 } // namespace Completer
762 } // namespace CASM
763 
764 #endif
static std::string path()
Get value_type string for path completion.
Definition: Handlers.cc:56
static const std::vector< std::pair< std::string, ARG_TYPE > > m_argument_table
Definition: Handlers.hh:188
static void ref_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for REF.
Definition: Handlers.cc:215
static std::string configname()
Get value_type string for configuration completion.
Definition: Handlers.cc:66
static void infomethod_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:261
static void void_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:92
static std::string dof()
Get value_type string for property mode completion.
Definition: Handlers.cc:88
static void configtype_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:175
static std::string configtype()
Get value_type string for configtype mode completion.
Definition: Handlers.cc:74
static void dof_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for DOF.
Definition: Handlers.cc:250
static ARG_TYPE determine_type(const po::option_description &boost_option)
Definition: Handlers.cc:28
static void eci_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for ECI.
Definition: Handlers.cc:226
static void calctype_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:182
static std::string operation()
Get value_type string for operation completion.
Definition: Handlers.cc:64
static std::string calctype()
Get value_type string for calctype mode completion.
Definition: Handlers.cc:76
static void operator_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:128
static void clex_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for CLEX.
Definition: Handlers.cc:204
static std::string property()
Get value_type string for property mode completion.
Definition: Handlers.cc:86
static std::string enummethod()
Get value_type string for enummethod mode completion.
Definition: Handlers.cc:72
static void property_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:239
static std::string eci()
Get value_type string for eci mode completion.
Definition: Handlers.cc:84
static std::string coordtype()
Get value_type string for coordinate mode completion.
Definition: Handlers.cc:68
static std::string infomethod()
Get value_type string for infomethod mode completion.
Definition: Handlers.cc:90
static std::string query()
Get value_type string for query completion.
Definition: Handlers.cc:62
static std::string dbtype()
Get value_type string for dbtype mode completion.
Definition: Handlers.cc:70
static std::string ref()
Get value_type string for ref mode completion.
Definition: Handlers.cc:82
static void command_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:99
static void scelname_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:104
static void dbtype_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for DBTYPE.
Definition: Handlers.cc:160
static void bset_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for BSET.
Definition: Handlers.cc:193
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
Definition: Handlers.cc:58
static std::string bset()
Get value_type string for bset mode completion.
Definition: Handlers.cc:78
static void path_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for PATH.
Definition: Handlers.cc:94
static void enummethod_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:167
static std::string clex()
Get value_type string for clex mode completion.
Definition: Handlers.cc:80
static void query_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for QUERY.
Definition: Handlers.cc:140
static std::string supercell()
Get value_type string for supercell completion.
Definition: Handlers.cc:60
static void configname_to_bash(std::vector< std::string > &arguments)
Definition: Handlers.cc:116
OptionHandlerBase(const std::string &init_option_tag)
Define the name of the command during construction.
Definition: Handlers.cc:298
std::set< std::string > db_type_opts() const
Definition: Handlers.cc:557
std::string configtype() const
Definition: Handlers.cc:530
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
Definition: Handlers.cc:398
void add_selections_suboption(const fs::path &_default="MASTER")
Add –selections suboption (defaults to MASTER)
Definition: Handlers.cc:443
const std::vector< std::string > & config_strs() const
Definition: Handlers.cc:382
fs::path m_file_path
The path string to go with add_file_path_suboption.
Definition: Handlers.hh:316
void add_prim_path_suboption(const fs::path &_default="")
Add –prim suboption.
Definition: Handlers.cc:500
void add_input_suboption(bool required=true)
Definition: Handlers.cc:610
fs::path m_selection_path
The selection string to go with add_config_suboption.
Definition: Handlers.hh:280
std::vector< std::string > m_dof_strs
The list of DoF type names.
Definition: Handlers.hh:525
void add_confignames_suboption()
Add a –confignames suboption.
Definition: Handlers.cc:691
void add_names_suboption()
Add a –names suboption.
Definition: Handlers.cc:706
std::string m_config_str
The name of a single configname to go with add_configname_suboption()
Definition: Handlers.hh:474
po::variables_map m_vm
Boost program options variable map.
Definition: Handlers.hh:263
const po::options_description & desc()
Get the program options, filled with the initialized values.
Definition: Handlers.cc:321
std::vector< fs::path > m_selection_paths
The selection string to go with add_config_suboption.
Definition: Handlers.hh:294
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
void add_scelname_suboption()
Add a –scelname suboption.
Definition: Handlers.cc:654
static std::string default_dry_run_msg()
Definition: Handlers.cc:753
std::vector< std::string > m_help_opt_vec
The list of strings to go with add_general_help_suboption()
Definition: Handlers.hh:375
std::string m_configtype
User-specified config type.
Definition: Handlers.hh:338
po::variables_map & vm()
Get the variables map.
Definition: Handlers.cc:310
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
Definition: Handlers.cc:372
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:338
void add_settings_suboption(bool required=true)
Definition: Handlers.cc:588
void add_help_suboption()
Add a plain –help and –desc suboptions.
Definition: Handlers.cc:561
std::vector< std::string > m_name_strs
The list of the supercell names of add_configname_suboption()
Definition: Handlers.hh:498
fs::path m_output_path
The path that goes with add_output_suboption.
Definition: Handlers.hh:429
const std::vector< std::string > & name_strs() const
Definition: Handlers.cc:721
void add_configlists_suboption(const fs::path &_default="MASTER")
Add –configs suboption (defaults to MASTER)
Definition: Handlers.cc:455
const fs::path & prim_path() const
Returns the string corsresponding to add_prim_path_suboption()
Definition: Handlers.cc:348
std::vector< std::string > m_config_strs
The list of the supercell names of add_configname_suboption()
Definition: Handlers.hh:486
po::options_description m_desc
Definition: Handlers.hh:260
const std::string & coordtype_str() const
Return the coordinate type in the form of a string.
Definition: Handlers.cc:394
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
Definition: Handlers.cc:364
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
Definition: Handlers.cc:431
std::set< std::string > configtype_opts() const
Definition: Handlers.cc:532
int verbosity() const
Will throw if not expected string or int in range [0, 100].
Definition: Handlers.cc:355
void add_db_type_suboption(std::string _default, std::set< std::string > _configtype_opts)
Definition: Handlers.cc:536
std::string m_tag
name of the casm command
Definition: Handlers.hh:256
void add_selection_no_default_suboption()
Add –selection suboption (no default)
Definition: Handlers.cc:420
std::string m_verbosity_str
The verbosity string to go with add_config_suboption.
Definition: Handlers.hh:387
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
Definition: Handlers.cc:725
std::set< std::string > m_configtype_opts
Set of valid config types.
Definition: Handlers.hh:341
const std::vector< std::string > & help_opt_vec() const
Returns the list of strings corresponding to add_general_help_suboption()
Definition: Handlers.cc:374
std::string m_input_str
The settings path to go with add_input_suboption()
Definition: Handlers.hh:402
void add_dry_run_suboption(std::string msg=default_dry_run_msg())
Definition: Handlers.cc:749
void add_configtype_suboption(std::string _default, std::set< std::string > _configtype_opts)
Add –type suboption (default, set of short_name of allowed ConfigTypes)
Definition: Handlers.cc:511
const std::vector< std::string > & dof_strs() const
Returns the names of the DoF type names for add_dofs_suboption()
Definition: Handlers.cc:403
void add_general_help_suboption()
Add a smart –help suboption that takes "properties" or "operators".
Definition: Handlers.cc:567
bool m_gzip_flag
The bool that goes with add_gzip_suboption.
Definition: Handlers.hh:441
void add_scelnames_suboption()
Add a –scelnames suboption.
Definition: Handlers.cc:665
virtual void initialize()=0
Fill in the options descriptions accordingly.
std::vector< std::string > m_supercell_strs
The list of supercell names of add_scelnames_suboption()
Definition: Handlers.hh:463
std::string db_type() const
Definition: Handlers.cc:555
void add_dofs_suboption()
Add a –dofs suboption to specify DoF Types.
Definition: Handlers.cc:737
const std::string & supercell_str() const
Returns the name of the supercell for add_scelname_suboption()
Definition: Handlers.cc:386
const std::string & config_str() const
Definition: Handlers.cc:378
void add_configname_suboption()
Add a –configname suboption.
Definition: Handlers.cc:677
void add_file_path_suboption(const fs::path &_default="")
Add –path suboption (defaults to MASTER)
Definition: Handlers.cc:490
std::set< std::string > m_db_type_opts
Set of valid config types.
Definition: Handlers.hh:358
void add_configlists_nodefault_suboption()
Add –configs suboption (no default)
Definition: Handlers.cc:478
std::string m_db_type
User-specified config type.
Definition: Handlers.hh:355
const fs::path & file_path() const
Returns the string corsresponding to add_file_path_suboption()
Definition: Handlers.cc:346
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:342
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
Definition: Handlers.cc:467
void add_selection_suboption(const fs::path &_default="MASTER")
Add –selection suboption (defaults to MASTER)
Definition: Handlers.cc:407
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
Definition: Handlers.cc:626
const std::string & verbosity_str() const
Returns the string corresponding to add_verbosity_suboption()
Definition: Handlers.cc:350
fs::path m_prim_path
The path string to go with add_prim_path_suboption.
Definition: Handlers.hh:305
const std::string & tag() const
Definition: Handlers.cc:307
fs::path m_settings_path
The settings path to go with add_settings_suboption()
Definition: Handlers.hh:414
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
Definition: Handlers.cc:370
std::string m_supercell_str
The string of the supercell name of add_scelname_suboption()
Definition: Handlers.hh:452
Parsing dictionary for constructing a DataFormatter<DataObject> object.
Specification of CASM project directory structure.
static std::string invalid_verbosity_msg(std::string s)
Definition: Log.cc:219
static std::pair< bool, int > verbosity_level(std::string s)
Read verbosity level from a string.
Definition: Log.cc:231
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
const_iterator cend() const
Definition: unique_map.hh:223
iterator begin()
Definition: unique_map.hh:213
std::string standard_singleline_help(StringContainer options, std::string _default="")
Print short help message describing recognized strings for allowed enum values.
Definition: io_traits.hh:83
const DB::Database< T > & const_db() const
Definition: PrimClex.cc:307
ProjectSettings open_project_settings(fs::path path_in_project)
ArgHandler::ARG_TYPE ARG_TYPE
Definition: Complete.cc:11
ConfigIO::GenericConfigFormatter< jsonParser > config()
Definition: ConfigIO.cc:777
const std::set< std::string > & types_short()
std::set of all QueryTraits<DataObject>::short_name
const std::set< std::string > & config_types_short()
std::set of all QueryTraits<ConfigType>::short_name
Main CASM namespace.
Definition: APICommand.hh:8
COORD_TYPE
Definition: enum.hh:6
InfoInterfaceVector make_standard_info_method_interfaces()
A vector containing casm info method interfaces.
fs::path find_casmroot(const fs::path &cwd)
EnumInterfaceVector make_standard_enumerator_interfaces()
std::string help()
Uses 'multiline_help<T>()' by default.
Definition: Help.hh:22
Definition: stream_io.hh:24
DirectoryStructure const & dir
Definition: settings.cc:136
ProjectSettings & set
Definition: settings.cc:137
Specifies a particular cluster expansion.