17 return vm().count(
"force");
21 return vm().count(
"dry-run");
31 (
"dry-run,n",
"Dry run")
32 (
"force,f",
"Force remove.");
49 po::variables_map &vm = rm_opt.
vm();
51 bool rm_config =
false;
55 po::store(po::parse_command_line(args.
argc, args.
argv, rm_opt.
desc()), vm);
57 bool call_help =
false;
60 if(!vm.count(
"help") && !vm.count(
"desc")) {
62 rm_config = vm.count(
"config") + vm.count(
"confignames");
63 rm_scel = vm.count(
"scelnames");
65 if(!rm_config && !rm_scel) {
66 args.
log <<
"Error in 'casm rm': At least one of --config, "
67 "--confignames, --scelnames must be given." << std::endl;
71 if(rm_config + rm_scel > 1) {
72 args.
log <<
"Error in 'casm rm': May not delete multiple types at the same time." << std::endl;
79 if(vm.count(
"help") || call_help) {
81 args.
log << rm_opt.
desc() << std::endl;
86 if(vm.count(
"desc")) {
88 args.
log << rm_opt.
desc() << std::endl;
89 args.
log <<
"DESCRIPTION" << std::endl;
90 args.
log <<
" Remove configuration data and supercells.\n"
93 " - A supercell, including all enumerated configurations \n"
94 " and data (for all calctypes) via --scelnames.\n"
95 " - Calculation data (for the current calctype) for \n"
96 " individual configurations via --config or --confignames.\n\n"
99 " - Specific enumerated configuration. The current version \n"
100 " of CASM is restricted to consequitively numbered \n"
101 " configurations in each supercell, so configurations may\n"
102 " only be erased by erasing a supercell.\n\n";
111 catch(po::error &e) {
112 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
116 catch(std::exception &e) {
117 args.
err_log <<
"Unhandled Exception reached the top of main: "
118 << e.what() <<
", application will now exit" << std::endl;
146 std::unique_ptr<PrimClex> uniq_primclex;
150 std::unique_ptr<ConstConfigSelection> selection;
151 if(rm_opt.
vm().count(
"config")) {
154 else if(rm_opt.
vm().count(
"confignames")) {
155 selection = notstd::make_unique<ConstConfigSelection>(
primclex,
fs::path(
"NONE"));
162 args.
log <<
"dry-run...\n\n";
165 for(
auto it = selection->selected_config_begin(); it != selection->selected_config_end(); ++it) {
166 args.
log.
custom(std::string(
"Erase ") + it->name() +
" data");
167 if(rm_opt.
force() && fs::exists(it->calc_dir())) {
170 else if(fs::exists(it->calc_dir())) {
171 args.
log <<
"skipping " << it->name() <<
" data: --force option not given\n";
174 args.
log <<
"skipping " << it->name() <<
" data: no data\n";
186 std::unique_ptr<PrimClex> uniq_primclex;
190 std::set<std::string> scel_to_delete;
196 args.
log <<
"skipping " <<
scelname <<
": does not exist.\n";
204 << scel.
get_config_list().size() <<
" configurations and --force not given.\n";
212 args.
log << std::endl;
215 if(!scel_to_delete.size()) {
216 args.
log <<
"No supercells to erase\n";
219 for(
const auto &
scelname : scel_to_delete) {
Data structure holding basic CASM command info.
int _rm_scel(const CommandArgs &args, const Completer::RmOption &rm_opt)
void write_config_list(std::set< std::string > scel_to_delete={})
void add_scelnames_suboption()
Add a –scelnames suboption.
int _rm_configs(const CommandArgs &args, const Completer::RmOption &rm_opt)
int rm_command(const CommandArgs &args)
void add_help_suboption()
Add a plain –help suboption.
ConfigList & get_config_list()
Represents a supercell of the primitive parent crystal structure.
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
fs::path get_path() const
Return path to supercell directory.
void custom(const std::string &what)
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
const po::options_description & desc()
Get the program options, filled with the initialized values.
EigenIndex Index
For long integer indexing:
void recurs_rm_files(fs::path p, bool dry_run, Log &log)
Remove files recursively.
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
const std::vector< std::string > & config_strs() const
Returns the names of the supercells for add_configname_suboption(), for when multiple=false.
PrimClex is the top-level data structure for a CASM project.
void add_confignames_suboption()
Add a –confignames suboption.
void print_supercells(std::set< std::string > scel_to_delete={}) const
const std::vector< std::string > & supercell_strs() const
Returns the list of the supercells for add_scelnames_suboption()
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
void initialize() override
Fill in the options descriptions accordingly.
po::variables_map & vm()
Get the variables map.
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 Supercell & get_supercell(Index i) const
const Access supercell by index
void error(const std::string &what)
ConfigIO::GenericConfigFormatter< std::string > scelname()
bool contains_supercell(std::string scellname, Index &index) const