28 "Which settings to include. "
29 "One of: 'curr' (default), 'all'.")
31 (
"calc", po::value<std::vector<std::string> >(&
m_calc_vec)->multitoken(),
32 "Which calculation files to include. "
33 "May be zero (default) or more of: 'settings', 'status', 'all'.")
39 (
"relative,R",
"Print relative path from project root directory.");
51 std::vector<std::string>
60 po::parse_command_line(args.
argc(), args.
argv(), files_opt.
desc()),
63 if (!vm.count(
"help")) {
64 std::vector<std::string> allowed;
66 allowed = std::vector<std::string>{
"",
"curr",
"all"};
68 err_log() <<
"Error in 'casm files'. '" << settings
69 <<
"' is not a valid option to --settings." << std::endl;
70 err_log() <<
" Valid options are: 'curr', 'all'" << std::endl;
74 allowed = std::vector<std::string>{
"settings",
"status",
"all"};
75 for (
auto it = calc.begin(); it != calc.end(); ++it) {
77 err_log() <<
"Error in 'casm files'. '" << *it
78 <<
"' is not a valid option to --calc." << std::endl;
79 err_log() <<
" Valid options are: 'settings', 'status', 'all'"
88 if (vm.count(
"help")) {
90 log() << files_opt.
desc() << std::endl;
95 if (vm.count(
"desc")) {
97 log() << files_opt.
desc() << std::endl;
101 " Enumerate files used by this CASM project\n"
102 " - If --all given, include files from all settings (bset, \n"
103 " calctype, ref, clex, eci). Otherwise only include files\n"
104 " relevant to the current settings.\n"
105 " - If --calc given, include training data files. This option\n"
106 " accepts one or more of: 'settings', 'status', or 'all'.\n"
107 " 'settings': include files from the 'training_data' \n"
108 " settings directories.\n"
109 " 'status': include 'properties.calc.json' and \n"
110 " 'status.json' files.\n"
111 " 'all': include all files in the 'training_data'\n"
112 " directory, recursively.\n\n"
116 " - Prints basic project files for the current settings.\n"
117 " - Prints absolute paths.\n\n"
120 " - Prints basic project files for the current settings.\n"
121 " - Prints relative paths from project root directory.\n\n"
123 " casm files -o absfiles.txt\n"
124 " - Write 'absfiles.txt' with basic project files for \n"
125 " the current settings.\n"
126 " - Prints absolute paths.\n\n"
128 " casm files -R -o relfiles.txt\n"
129 " - Write 'relfiles.txt' with basic project files for \n"
130 " the current settings.\n"
131 " - Prints relative paths from project root directory.\n\n"
133 " tar -czvf proj.tar.gz `casm files -o STDOUT` \n"
134 " tar -czvf proj.tar.gz -T absfiles.txt \n"
135 " - Use tar to create an archive of your CASM project. \n"
136 " - Extract with 'tar -xzvf proj.tar.gz'. \n\n"
138 " rsync -avPR `casm files -R -o STDOUT` destination -n \n"
139 " - Copy project files to the 'destination' directory, \n"
140 " creating sub-directories as necessary. \n"
141 " - **Must run from project root directory** \n"
142 " - Replace 'destination' with '-e ssh "
143 "user@host:destination' \n"
144 " for a remote destination.\n"
145 " - \"-n\" option is for a \"dry-run\". Remove it when ready "
147 " to do the transfer.\n\n"
149 " rsync -avPR --files-from=relfiles.txt src destination -n \n"
150 " - Copy project files to the 'destination' directory, \n"
151 " creating sub-directories as necessary. \n"
152 " - 'src' is the path to the root directory of the CASM\n"
153 " project you are copying from. \n"
154 " - Replace 'destination' with '-e ssh "
155 "user@host:destination' \n"
156 " for a remote destination.\n"
157 " - \"-n\" option is for a \"dry-run\". Remove it when ready "
159 " to do the transfer.\n";
172 }
catch (po::error &e) {
174 err_log() <<
"ERROR: " << e.what() << std::endl << std::endl;
176 }
catch (std::exception &e) {
178 err_log() <<
"ERROR: " << e.what() << std::endl << std::endl;
182 auto check_gz = [=](fs::path p) {
183 if (p.extension() ==
".gz" || p.extension() ==
".GZ") {
189 if (check_gz(out_path)) {
193 const fs::path &root = args.
root;
202 std::unique_ptr<PrimClex> uniq_primclex;
203 Log &status_log = (out_path.string() ==
"STDOUT") ?
err_log() :
log();
204 auto logging = notstd::make_unique<ScopedLogging>(status_log,
err_log());
208 std::vector<fs::path> files;
209 auto result = std::back_inserter(files);
217 bool calc_settings =
contains(calc,
"settings");
219 bool calc_all =
contains(calc,
"all");
221 if (calc_settings && !calc_all) {
232 std::unique_ptr<std::ostream> uniq_fout;
233 std::ostream &output_stream =
236 for (
auto f : files) {
237 output_stream << f.string() <<
"\n";
std::vector< std::string > m_calc_vec
const std::string & settings_str() const
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
void initialize() override
Fill in the options descriptions accordingly.
std::string m_settings_str
const std::vector< std::string > & calc_vec() const
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
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_gzip_suboption()
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
Lists all files in a CASM project, for use with 'casm files' command.
OutputIterator all_calc_files(OutputIterator result)
Enumerate all training data files.
OutputIterator calc_status_files(OutputIterator result)
Enumerate calculation status files.
OutputIterator reference_files(OutputIterator result)
Enumerate reference files.
OutputIterator eci_files(OutputIterator result)
Enumerate eci files.
OutputIterator calc_settings_files(OutputIterator result)
Enumerate calculation settings files.
OutputIterator bset_files(OutputIterator result)
Enumerate bset files.
OutputIterator basic_files(OutputIterator result)
Enumerate all setting independent files.
void error(const std::string &what)
PrimClex is the top-level data structure for a CASM project.
std::ostream & make_ostream_if(bool output, std::ostream &sout, std::unique_ptr< std::ostream > &fout, fs::path out_path, bool gzip)
Return a reference to proper std::ostream.
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...
int files_command(const CommandArgs &args)
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value)
std::string calc_status(const ConfigType &_config, std::string calctype="")
Status of calculation.
Data structure holding basic CASM command info.