29 "Which settings to include. "
30 "One of: 'curr' (default), 'all'.")
33 po::value<std::vector<std::string> >(&
m_calc_vec)->multitoken(),
34 "Which calculation files to include. "
35 "May be zero (default) or more of: 'settings', 'status', 'all'.")
38 "Print relative path from project root directory.");
52 std::vector<std::string> calc;
59 po::store(po::parse_command_line(args.
argc, args.
argv, files_opt.
desc()), vm);
61 if(!vm.count(
"help")) {
63 std::vector<std::string> allowed;
65 allowed = std::vector<std::string> {
"",
"curr",
"all"};
67 args.
err_log <<
"Error in 'casm files'. '" << settings <<
"' is not a valid option to --settings." << std::endl;
68 args.
err_log <<
" Valid options are: 'curr', 'all'" << std::endl;
72 allowed = std::vector<std::string> {
"settings",
"status",
"all"};
73 for(
auto it = calc.begin(); it != calc.end(); ++it) {
75 args.
err_log <<
"Error in 'casm files'. '" << *it <<
"' is not a valid option to --calc." << std::endl;
76 args.
err_log <<
" Valid options are: 'settings', 'status', 'all'" << std::endl;
84 if(vm.count(
"help")) {
86 args.
log << files_opt.
desc() << std::endl;
91 if(vm.count(
"desc")) {
93 args.
log << files_opt.
desc() << std::endl;
95 args.
log <<
"DESCRIPTION \n"
96 " Enumerate files used by this CASM project\n"
97 " - If --all given, include files from all settings (bset, \n"
98 " calctype, ref, clex, eci). Otherwise only include files\n"
99 " relevant to the current settings.\n"
100 " - If --calc given, include training data files. This option\n"
101 " accepts one or more of: 'settings', 'status', or 'all'.\n"
102 " 'settings': include files from the 'training_data' \n"
103 " settings directories.\n"
104 " 'status': include 'properties.calc.json' and \n"
105 " 'status.json' files.\n"
106 " 'all': include all files in the 'training_data'\n"
107 " directory, recursively.\n\n"
111 " - Prints basic project files for the current settings.\n"
112 " - Prints absolute paths.\n\n"
115 " - Prints basic project files for the current settings.\n"
116 " - Prints relative paths from project root directory.\n\n"
118 " casm files -o absfiles.txt\n"
119 " - Write 'absfiles.txt' with basic project files for \n"
120 " the current settings.\n"
121 " - Prints absolute paths.\n\n"
123 " casm files -R -o relfiles.txt\n"
124 " - Write 'relfiles.txt' with basic project files for \n"
125 " the current settings.\n"
126 " - Prints relative paths from project root directory.\n\n"
128 " tar -czvf proj.tar.gz `casm files -o STDOUT` \n"
129 " tar -czvf proj.tar.gz -T absfiles.txt \n"
130 " - Use tar to create an archive of your CASM project. \n"
131 " - Extract with 'tar -xzvf proj.tar.gz'. \n\n"
133 " rsync -avPR `casm files -R -o STDOUT` destination -n \n"
134 " - Copy project files to the 'destination' directory, \n"
135 " creating sub-directories as necessary. \n"
136 " - **Must run from project root directory** \n"
137 " - Replace 'destination' with '-e ssh user@host:destination' \n"
138 " for a remote destination.\n"
139 " - \"-n\" option is for a \"dry-run\". Remove it when ready \n"
140 " to do the transfer.\n\n"
142 " rsync -avPR --files-from=relfiles.txt src destination -n \n"
143 " - Copy project files to the 'destination' directory, \n"
144 " creating sub-directories as necessary. \n"
145 " - 'src' is the path to the root directory of the CASM\n"
146 " project you are copying from. \n"
147 " - Replace 'destination' with '-e ssh user@host:destination' \n"
148 " for a remote destination.\n"
149 " - \"-n\" option is for a \"dry-run\". Remove it when ready \n"
150 " to do the transfer.\n";
165 catch(po::error &e) {
167 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
170 catch(std::exception &e) {
172 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
177 if(p.extension() ==
".gz" || p.extension() ==
".GZ") {
183 if(check_gz(out_path)) {
196 std::unique_ptr<std::ostream> uniq_fout;
197 std::ostream &output_stream =
make_ostream_if(vm.count(
"output"), args.
log, uniq_fout, out_path, gz_flag);
200 Log &status_log = (out_path.string() ==
"STDOUT") ? args.
err_log : args.
log;
204 std::unique_ptr<PrimClex> uniq_primclex;
207 std::vector<fs::path> files;
208 auto result = std::back_inserter(files);
212 result = enumerate.bset_files(result);
213 result = enumerate.reference_files(result);
214 result = enumerate.eci_files(result);
216 bool calc_settings =
contains(calc,
"settings");
218 bool calc_all =
contains(calc,
"all");
220 if(calc_settings && !calc_all) {
221 result = enumerate.calc_settings_files(result);
223 if(calc_status && !calc_all) {
224 result = enumerate.calc_status_files(result);
227 result = enumerate.all_calc_files(result);
230 for(
auto f : files) {
231 output_stream << f.string() <<
"\n";
Data structure holding basic CASM command info.
std::vector< std::string > m_calc_vec
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
void add_help_suboption()
Add a plain –help suboption.
int files_command(const CommandArgs &args)
OutputIterator basic_files(OutputIterator result)
Enumerate all setting independent files.
const po::options_description & desc()
Get the program options, filled with the initialized values.
void initialize() override
Fill in the options descriptions accordingly.
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
PrimClex is the top-level data structure for a CASM project.
void add_gzip_suboption()
Add a –gzip suboption. The value will default to false unless overridden by the derived class...
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.
Lists all files in a CASM project, for use with 'casm files' command.
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...
const std::string & settings_str() const
const std::vector< std::string > & calc_vec() const
void error(const std::string &what)
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
std::string calc_status(const Configuration &_config)
Status of calculation.
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value) ...
std::string m_settings_str