24 m_desc.add_options()(
"exec,e",
28 "Command to execute");
49 po::store(po::parse_command_line(args.
argc(), args.
argv(), run_opt.
desc()),
54 if (vm.count(
"help")) {
56 log() << run_opt.
desc() << std::endl;
61 if (vm.count(
"desc")) {
63 log() << run_opt.
desc() << std::endl;
64 log() <<
"DESCRIPTION\n"
65 <<
" Executes the requested command for each selected "
67 <<
" with the path to the configuration as an argument. "
69 <<
" Example: casm run --exec \"vasp.relax\"\n"
71 <<
" 'vasp.relax $ROOT/training_data/$SCELNAME/$CONFIGID'\n"
72 <<
" for each config selected in config_list\n\n";
81 }
catch (po::error &e) {
82 err_log() <<
"ERROR: " << e.what() << std::endl << std::endl;
85 }
catch (std::exception &e) {
86 err_log() <<
"ERROR: " << e.what() <<
".\n Exiting..." << std::endl;
90 const fs::path &root = args.
root;
99 std::unique_ptr<PrimClex> uniq_primclex;
103 if (!vm.count(
"config") || (selection ==
"MASTER")) {
104 selection =
"MASTER";
105 }
else if (vm.count(
"config") && !fs::exists(selection)) {
106 std::cerr <<
"ERROR: Invalid input. Option '--config' accepts one "
107 "argument (either 'MASTER' or a path to a valid "
108 "configuration selection file)."
127 }
catch (std::exception &e) {
128 err_log() <<
"ERROR: Invalid input. Option '--config' accepts one argument "
129 "(either 'MASTER' or a path to a valid configuration "
136 log() <<
"\n***************************\n" << std::endl;
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
const po::options_description & desc()
Get the program options, filled with the initialized values.
void add_help_suboption()
Add a plain –help and –desc suboptions.
po::options_description m_desc
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
void initialize() override
Fill in the options descriptions accordingly.
const std::string & exec_str() const
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
boost::iterator_range< iterator > selected()
fs::path configuration_dir(std::string configname) const
Return configuration directory path.
void error(const std::string &what)
Remember how to use popen.
void popen(std::string _command)
Execute popen for a given command.
void print(std::ostream &sout) const
Print the last command executed and the resulting stdout.
PrimClex is the top-level data structure for a CASM project.
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...
DB::Database< T > & db() const
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
ConfigIO::GenericConfigFormatter< jsonParser > config()
void write_config_json(Configuration const &configuration, DirectoryStructure const &dir)
void write_pos(Configuration const &configuration, DirectoryStructure const &dir)
Write configuration "POS" file (VASP POSCAR) to standard location.
int run_command(const CommandArgs &args)
Data structure holding basic CASM command info.