44 po::store(po::parse_command_line(args.
argc, args.
argv, run_opt.
desc()), vm);
48 if(vm.count(
"help")) {
50 args.
log << run_opt.
desc() << std::endl;
55 if(vm.count(
"desc")) {
57 args.
log << run_opt.
desc() << std::endl;
58 args.
log <<
"DESCRIPTION\n"
59 <<
" Executes the requested command for each selected configuration,\n"
60 <<
" with the path to the configuration as an argument. \n\n"
61 <<
" Example: casm run --exec \"vasp.relax\"\n"
63 <<
" 'vasp.relax $ROOT/training_data/$SCELNAME/$CONFIGID'\n"
64 <<
" for each config selected in config_list\n\n";
75 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
79 catch(std::exception &e) {
80 args.
err_log <<
"ERROR: " << e.what() <<
".\n Exiting..." << std::endl;
94 std::unique_ptr<PrimClex> uniq_primclex;
96 const auto &
dir = primclex.
dir();
99 if(!vm.count(
"config") || (selection ==
"MASTER")) {
101 if(!fs::exists(
dir.
POS(it->name()))) {
107 process.
popen(run_opt.
exec_str() +
" " + it->get_path().string());
112 else if(vm.count(
"config") && fs::exists(selection)) {
115 if(!fs::exists(
dir.
POS(it->name()))) {
121 process.
popen(run_opt.
exec_str() +
" " + it->get_path().string());
128 args.
err_log <<
"ERROR: Invalid input. Option '--config' accepts one argument (either 'MASTER' or a path to a valid configuration selection file)." << std::endl
133 catch(std::exception &e) {
134 args.
err_log <<
"ERROR: Invalid input. Option '--config' accepts one argument (either 'MASTER' or a path to a valid configuration selection file)." << std::endl
142 args.
log <<
"\n***************************\n" << std::endl;
144 args.
log << std::endl;
const std::string & exec_str() const
Data structure holding basic CASM command info.
const DirectoryStructure & dir() const
void add_help_suboption()
Add a plain –help suboption.
iterator selected_config_begin()
void popen(std::string _command)
Execute popen for a given command.
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
void print(std::ostream &sout) const
Print the last command executed and the resulting stdout.
config_iterator selected_config_end()
Configuration iterator: end.
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
Remember how to use popen.
const po::options_description & desc()
Get the program options, filled with the initialized values.
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
int run_command(const CommandArgs &args)
iterator selected_config_end()
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
config_iterator selected_config_begin()
Configuration iterator: begin.
PrimClex is the top-level data structure for a CASM project.
fs::path POS(std::string configname) const
Return path to POS file.
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...
void error(const std::string &what)
void initialize() override
Fill in the options descriptions accordingly.