29 const po::option_description &boost_option) {
32 std::string raw_boost_format = boost_option.format_parameter();
34 std::string argtype_str;
38 if (space_pos != std::string::npos) {
39 argtype_str = raw_boost_format.substr(0, space_pos);
44 argtype_str = raw_boost_format;
48 if (it->first == argtype_str) {
53 return ARG_TYPE::VOID;
95 arguments.push_back(
"BASH_COMP_PATH");
100 arguments.push_back(
"BASH_COMP_BIN");
105 if (!
find_casmroot(boost::filesystem::current_path()).empty()) {
110 arguments.push_back(scel.name());
117 if (!
find_casmroot(boost::filesystem::current_path()).empty()) {
122 arguments.push_back(
config.name());
130 make_dictionary<Configuration>();
132 for (
auto it = dict.
begin(); it != dict.
cend(); ++it) {
134 arguments.push_back(it->name());
142 make_dictionary<Configuration>();
144 for (
auto it = config_dict.
begin(); it != config_dict.
cend(); ++it) {
146 arguments.push_back(
"config:" + it->name());
151 for (
auto it = scel_dict.
begin(); it != scel_dict.
cend(); ++it) {
153 arguments.push_back(
"scel:" + it->name());
162 arguments.push_back(item);
169 for (
auto const &e : enumerator_interfaces) {
170 arguments.push_back(e->name());
177 arguments.push_back(item);
183 auto checkroot =
find_casmroot(boost::filesystem::current_path());
184 if (!checkroot.empty()) {
186 for (
auto &item :
dir.all_calctype()) {
187 arguments.push_back(item);
194 auto checkroot =
find_casmroot(boost::filesystem::current_path());
195 if (!checkroot.empty()) {
197 for (
auto &item :
dir.all_bset()) {
198 arguments.push_back(item);
205 auto checkroot =
find_casmroot(boost::filesystem::current_path());
206 if (!checkroot.empty()) {
208 for (
auto &item :
set.cluster_expansions()) {
209 arguments.push_back(item.first);
216 auto checkroot =
find_casmroot(boost::filesystem::current_path());
217 if (!checkroot.empty()) {
219 for (
auto &item :
set.dir().all_ref(
set.default_clex().calctype)) {
220 arguments.push_back(item);
227 auto checkroot =
find_casmroot(boost::filesystem::current_path());
228 if (!checkroot.empty()) {
233 arguments.push_back(item);
240 auto checkroot =
find_casmroot(boost::filesystem::current_path());
241 if (!checkroot.empty()) {
243 for (
auto &item :
dir.all_property()) {
244 arguments.push_back(item);
251 auto checkroot =
find_casmroot(boost::filesystem::current_path());
252 if (!checkroot.empty()) {
263 for (
auto const &e : info_method_interfaces) {
264 arguments.push_back(e->name());
275 const std::vector<std::pair<std::string, ARG_TYPE> >
277 {std::make_pair(
"<path>", ARG_TYPE::PATH),
278 std::make_pair(
"<command>", ARG_TYPE::COMMAND),
279 std::make_pair(
"<supercell>", ARG_TYPE::SCELNAME),
280 std::make_pair(
"<query>", ARG_TYPE::QUERY),
281 std::make_pair(
"<operation>", ARG_TYPE::OPERATOR),
282 std::make_pair(
"<configuration>", ARG_TYPE::CONFIGNAME),
283 std::make_pair(
"<type>", ARG_TYPE::COORDTYPE),
284 std::make_pair(
"<dbtype>", ARG_TYPE::DBTYPE),
285 std::make_pair(
"<enummethod>", ARG_TYPE::ENUMMETHOD),
286 std::make_pair(
"<configtype>", ARG_TYPE::CONFIGTYPE),
287 std::make_pair(
"<calctype>", ARG_TYPE::CALCTYPE),
288 std::make_pair(
"<bset>", ARG_TYPE::BSET),
289 std::make_pair(
"<clex>", ARG_TYPE::CLEX),
290 std::make_pair(
"<ref>", ARG_TYPE::REF),
291 std::make_pair(
"<eci>", ARG_TYPE::ECI),
292 std::make_pair(
"<property>", ARG_TYPE::PROPERTY),
293 std::make_pair(
"<dof>", ARG_TYPE::DOF),
294 std::make_pair(
"<infomethod>", ARG_TYPE::INFOMETHOD)});
299 : m_tag(init_option_tag),
300 m_desc(
std::string(
"'casm ") + init_option_tag +
std::string(
"' usage")),
301 m_gzip_flag(false) {}
304 const std::string &init_descriptor)
305 : m_tag(init_option_tag), m_desc(init_descriptor), m_gzip_flag(false) {}
322 if (
m_desc.options().size() == 0) {
330 if (
m_desc.options().size() == 0) {
331 throw std::logic_error(
332 "code error: Options must be initialized by calling non-const desc()");
408 m_desc.add_options()(
"selection,c",
410 ->default_value(_default)
412 (std::string(
"Only consider the selected objects from "
413 "the given selection file. ") +
414 singleline_help<DB::SELECTION_TYPE>())
424 (std::string(
"Only consider the selected objects from the given "
425 "selection file. ") +
426 singleline_help<DB::SELECTION_TYPE>())
434 ->default_value(_default)
436 (std::string(
"Only consider the selected configurations "
437 "of the given selection file. ") +
438 singleline_help<DB::SELECTION_TYPE>())
446 ->default_value(std::vector<fs::path>{_default})
448 (std::string(
"Only consider the selected objects from "
449 "the given selection file. ") +
450 singleline_help<DB::SELECTION_TYPE>())
456 m_desc.add_options()(
"configs,c",
458 ->default_value(std::vector<fs::path>{_default})
460 (std::string(
"Only consider the selected configurations "
461 "of the given selection file. ") +
462 singleline_help<DB::SELECTION_TYPE>())
471 (std::string(
"Only consider the selected configurations of the given "
472 "selection file. ") +
473 standard_singleline_enum_help<DB::SELECTION_TYPE>(
"",
"filename"))
483 (std::string(
"Only consider the selected configurations of the given "
484 "selection files. ") +
485 standard_singleline_enum_help<DB::SELECTION_TYPE>(
"",
"filename"))
494 ->default_value(_default)
496 std::string(
"Path to directory in which to run the command. ").c_str());
501 m_desc.add_options()(
"prim",
503 ->default_value(_default)
505 std::string(
"Path to prim.json or POSCAR-like file that "
506 "defines project reference crystal. ")
512 std::string _default, std::set<std::string> _configtype_opts) {
513 if (!_configtype_opts.size()) {
519 std::stringstream
help;
520 help <<
"Type of configurations. "
523 m_desc.add_options()(
"type,t",
525 ->default_value(_default)
537 std::string _default, std::set<std::string> _db_type_opts) {
538 if (!_db_type_opts.size()) {
544 std::stringstream
help;
545 help <<
"Type of database objects. "
548 m_desc.add_options()(
"type,t",
550 ->default_value(_default)
562 m_desc.add_options()(
"help,h",
"Print help message")(
563 "desc",
"Print extended usage description");
573 "Print general help. Use '--help properties' for a list of query-able "
574 "properties or '--help operators' for a list of query operators");
583 "Verbosity of output. Options are 'none', 'quiet', 'standard', "
584 "'verbose', 'debug', or an integer 0-100 (0: none, 100: debug).");
589 std::string help_str =
590 "Settings input file specifying which parameters should be used. See "
595 m_desc.add_options()(
"settings,s",
611 std::string help_str =
612 "String specifying input settings. See 'casm format --" +
tag() +
"'.";
615 m_desc.add_options()(
"input,i",
630 "Name for output file. Use STDOUT to print results without extra "
636 m_desc.add_options()(
"output,o",
638 ->default_value(_default)
640 (std::string(
"Name for output file. ") +
641 "Use STDOUT to print results without extra messages."
642 "If not specified, '" +
643 _default.string() +
"' will be used.")
650 "Write gzipped output file.");
655 std::string help_str;
656 help_str =
"Single supercell name to use casm " +
m_tag +
657 " with, such as 'SCEL4_2_2_1_0_0_0'";
658 m_desc.add_options()(
"scelname",
666 std::string help_str;
667 help_str =
"One or more supercells to use casm " +
m_tag +
668 " with, such as 'SCEL4_2_2_1_0_0_0'";
669 m_desc.add_options()(
"scelnames",
678 std::string help_str;
680 help_str =
"Single configuration to use casm " +
m_tag +
681 " with, such as 'SCEL4_2_2_1_0_0_0/3'";
683 m_desc.add_options()(
"configname",
692 std::string help_str;
694 help_str =
"One or more configurations to use casm " +
m_tag +
695 " with, such as 'SCEL4_2_2_1_0_0_0/3'";
697 m_desc.add_options()(
"confignames",
707 std::string help_str;
709 help_str =
"One or more object names to use casm " +
m_tag +
710 " with, such as 'SCEL4_2_2_1_0_0_0/3'";
712 m_desc.add_options()(
"names",
726 m_desc.add_options()(
"coord",
728 ->default_value(
"frac")
730 (std::string(
"Type of coordinate system to use. ") +
731 singleline_help<COORD_TYPE>())
738 std::string help_str;
739 help_str =
"One or more DoF types to use casm " +
m_tag +
740 " with, such as 'disp' or 'EAstrain'";
741 m_desc.add_options()(
"dofs",
742 po::value<std::vector<std::string> >(&
m_dof_strs)
750 m_desc.add_options()(
"dry-run,n", msg.c_str());
754 return std::string(
"Dry run (if supported by method)");
static std::string path()
Get value_type string for path completion.
static const std::vector< std::pair< std::string, ARG_TYPE > > m_argument_table
static void ref_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for REF.
static std::string configname()
Get value_type string for configuration completion.
static void infomethod_to_bash(std::vector< std::string > &arguments)
static void void_to_bash(std::vector< std::string > &arguments)
static std::string dof()
Get value_type string for property mode completion.
static void configtype_to_bash(std::vector< std::string > &arguments)
static std::string configtype()
Get value_type string for configtype mode completion.
static void dof_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for DOF.
static ARG_TYPE determine_type(const po::option_description &boost_option)
static void eci_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for ECI.
static void calctype_to_bash(std::vector< std::string > &arguments)
static std::string operation()
Get value_type string for operation completion.
static std::string calctype()
Get value_type string for calctype mode completion.
static void operator_to_bash(std::vector< std::string > &arguments)
static void clex_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for CLEX.
static std::string property()
Get value_type string for property mode completion.
static std::string enummethod()
Get value_type string for enummethod mode completion.
static void property_to_bash(std::vector< std::string > &arguments)
static std::string eci()
Get value_type string for eci mode completion.
static std::string coordtype()
Get value_type string for coordinate mode completion.
static std::string infomethod()
Get value_type string for infomethod mode completion.
static std::string query()
Get value_type string for query completion.
static std::string dbtype()
Get value_type string for dbtype mode completion.
static std::string ref()
Get value_type string for ref mode completion.
static void command_to_bash(std::vector< std::string > &arguments)
static void scelname_to_bash(std::vector< std::string > &arguments)
static void dbtype_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for DBTYPE.
static void bset_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for BSET.
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
static std::string bset()
Get value_type string for bset mode completion.
static void path_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for PATH.
static void enummethod_to_bash(std::vector< std::string > &arguments)
static std::string clex()
Get value_type string for clex mode completion.
static void query_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for QUERY.
static std::string supercell()
Get value_type string for supercell completion.
static void configname_to_bash(std::vector< std::string > &arguments)
OptionHandlerBase(const std::string &init_option_tag)
Define the name of the command during construction.
std::set< std::string > db_type_opts() const
std::string configtype() const
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
void add_selections_suboption(const fs::path &_default="MASTER")
Add –selections suboption (defaults to MASTER)
std::string m_coordtype_str
const std::vector< std::string > & config_strs() const
fs::path m_file_path
The path string to go with add_file_path_suboption.
void add_prim_path_suboption(const fs::path &_default="")
Add –prim suboption.
void add_input_suboption(bool required=true)
fs::path m_selection_path
The selection string to go with add_config_suboption.
std::vector< std::string > m_dof_strs
The list of DoF type names.
void add_confignames_suboption()
Add a –confignames suboption.
void add_names_suboption()
Add a –names suboption.
std::string m_config_str
The name of a single configname to go with add_configname_suboption()
po::variables_map m_vm
Boost program options variable map.
const po::options_description & desc()
Get the program options, filled with the initialized values.
std::vector< fs::path > m_selection_paths
The selection string to go with add_config_suboption.
std::string input_str() const
Returns the path corresponding to add_input_suboption.
const std::vector< std::string > & supercell_strs() const
Returns the list of the supercells for add_scelnames_suboption()
void add_scelname_suboption()
Add a –scelname suboption.
static std::string default_dry_run_msg()
std::vector< std::string > m_help_opt_vec
The list of strings to go with add_general_help_suboption()
std::string m_configtype
User-specified config type.
po::variables_map & vm()
Get the variables map.
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
void add_settings_suboption(bool required=true)
void add_help_suboption()
Add a plain –help and –desc suboptions.
std::vector< std::string > m_name_strs
The list of the supercell names of add_configname_suboption()
fs::path m_output_path
The path that goes with add_output_suboption.
const std::vector< std::string > & name_strs() const
void add_configlists_suboption(const fs::path &_default="MASTER")
Add –configs suboption (defaults to MASTER)
const fs::path & prim_path() const
Returns the string corsresponding to add_prim_path_suboption()
std::vector< std::string > m_config_strs
The list of the supercell names of add_configname_suboption()
po::options_description m_desc
const std::string & coordtype_str() const
Return the coordinate type in the form of a string.
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
std::set< std::string > configtype_opts() const
int verbosity() const
Will throw if not expected string or int in range [0, 100].
void add_db_type_suboption(std::string _default, std::set< std::string > _configtype_opts)
std::string m_tag
name of the casm command
void add_selection_no_default_suboption()
Add –selection suboption (no default)
std::string m_verbosity_str
The verbosity string to go with add_config_suboption.
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
std::set< std::string > m_configtype_opts
Set of valid config types.
const std::vector< std::string > & help_opt_vec() const
Returns the list of strings corresponding to add_general_help_suboption()
std::string m_input_str
The settings path to go with add_input_suboption()
void add_dry_run_suboption(std::string msg=default_dry_run_msg())
void add_configtype_suboption(std::string _default, std::set< std::string > _configtype_opts)
Add –type suboption (default, set of short_name of allowed ConfigTypes)
const std::vector< std::string > & dof_strs() const
Returns the names of the DoF type names for add_dofs_suboption()
void add_general_help_suboption()
Add a smart –help suboption that takes "properties" or "operators".
void add_verbosity_suboption()
bool m_gzip_flag
The bool that goes with add_gzip_suboption.
void add_scelnames_suboption()
Add a –scelnames suboption.
virtual void initialize()=0
Fill in the options descriptions accordingly.
std::vector< std::string > m_supercell_strs
The list of supercell names of add_scelnames_suboption()
std::string db_type() const
void add_dofs_suboption()
Add a –dofs suboption to specify DoF Types.
const std::string & supercell_str() const
Returns the name of the supercell for add_scelname_suboption()
const std::string & config_str() const
void add_configname_suboption()
Add a –configname suboption.
void add_file_path_suboption(const fs::path &_default="")
Add –path suboption (defaults to MASTER)
std::set< std::string > m_db_type_opts
Set of valid config types.
void add_gzip_suboption()
void add_configlists_nodefault_suboption()
Add –configs suboption (no default)
std::string m_db_type
User-specified config type.
const fs::path & file_path() const
Returns the string corsresponding to add_file_path_suboption()
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
void add_selection_suboption(const fs::path &_default="MASTER")
Add –selection suboption (defaults to MASTER)
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
const std::string & verbosity_str() const
Returns the string corresponding to add_verbosity_suboption()
fs::path m_prim_path
The path string to go with add_prim_path_suboption.
const std::string & tag() const
fs::path m_settings_path
The settings path to go with add_settings_suboption()
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
std::string m_supercell_str
The string of the supercell name of add_scelname_suboption()
Specification of CASM project directory structure.
static std::string invalid_verbosity_msg(std::string s)
static std::pair< bool, int > verbosity_level(std::string s)
Read verbosity level from a string.
PrimClex is the top-level data structure for a CASM project.
Represents a supercell of the primitive parent crystal structure.
const_iterator cend() const
std::string standard_singleline_help(StringContainer options, std::string _default="")
Print short help message describing recognized strings for allowed enum values.
const DB::Database< T > & const_db() const
ProjectSettings open_project_settings(fs::path path_in_project)
ArgHandler::ARG_TYPE ARG_TYPE
ConfigIO::GenericConfigFormatter< jsonParser > config()
const std::set< std::string > & types_short()
std::set of all QueryTraits<DataObject>::short_name
const std::set< std::string > & config_types_short()
std::set of all QueryTraits<ConfigType>::short_name
InfoInterfaceVector make_standard_info_method_interfaces()
A vector containing casm info method interfaces.
fs::path find_casmroot(const fs::path &cwd)
EnumInterfaceVector make_standard_enumerator_interfaces()
std::string help()
Uses 'multiline_help<T>()' by default.
DirectoryStructure const & dir
Specifies a particular cluster expansion.