15 std::string raw_boost_format = boost_option.format_parameter();
17 std::string argtype_str;
18 std::string::size_type space_pos = raw_boost_format.find(
' ');
21 if(space_pos != std::string::npos) {
22 argtype_str = raw_boost_format.substr(0, space_pos);
27 argtype_str = raw_boost_format;
31 if(it->first == argtype_str) {
36 return ARG_TYPE::VOID;
73 arguments.push_back(
"BASH_COMP_PATH");
78 arguments.push_back(
"BASH_COMP_BIN");
89 for(
auto it = dict.
begin(); it != dict.
cend(); ++it) {
91 arguments.push_back(it->name());
100 for(
auto it = dict.
begin(); it != dict.
cend(); ++it) {
102 arguments.push_back(it->name());
116 std::make_pair(
"<path>", ARG_TYPE::PATH),
117 std::make_pair(
"<command>", ARG_TYPE::COMMAND),
118 std::make_pair(
"<supercell>", ARG_TYPE::SCELNAME),
119 std::make_pair(
"<query>", ARG_TYPE::QUERY),
120 std::make_pair(
"<operation>", ARG_TYPE::OPERATOR),
121 std::make_pair(
"<configuration>", ARG_TYPE::CONFIGNAME),
122 std::make_pair(
"<type>", ARG_TYPE::COORDTYPE)
129 m_tag(init_option_tag),
130 m_desc(
std::string(
"'casm ") + init_option_tag +
std::string(
"' usage")),
135 m_tag(init_option_tag),
136 m_desc(init_descriptor),
161 if(
m_desc.options().size() == 0) {
235 return selected_mode;
242 (std::string(
"Only consider the selected configurations of the given selection file. "
243 "Standard selections are 'MASTER', 'CALCULATED', 'ALL', or 'NONE'. "
244 "If not specified, '") + _default.string() + std::string(
"' will be used.")).c_str());
252 (std::string(
"Only consider the selected configurations of the given selection file. "
253 "Standard selections are 'MASTER', 'CALCULATED', 'ALL', or 'NONE'. "
254 "If not specified, '") + _default.string() + std::string(
"' will be used.")).c_str());
262 "Only consider the selected configurations of the given selection file. "
263 "Standard selections are 'MASTER', 'CALCULATED', 'ALL', or 'NONE'. ");
271 "Only consider the selected configurations of the given selection files. "
272 "Standard selections are 'MASTER', 'CALCULATED', 'ALL', or 'NONE'. ");
278 (
"help,h",
"Print help message")
279 (
"desc",
"Print extended usage description");
285 (
"help,h", po::value<std::vector<std::string> >(&
m_help_opt_vec)->multitoken()->zero_tokens(),
"Print general help. Use '--help properties' for a list of query-able properties or '--help operators' for a list of query operators");
292 (
"verbosity", po::value<std::string>(&
m_verbosity_str)->default_value(
"standard"),
"Verbosity of output. Options are 'none', 'quiet', 'standard', 'verbose', 'debug', or an integer 0-100 (0: none, 100: all).");
297 std::string help_str =
"Settings input file specifying which parameters should be used. See 'casm format --" +
m_tag +
"'.";
312 std::string help_str =
"String specifying input settings. See 'casm format --" +
m_tag +
"'.";
316 (
"input,i", po::value<std::string>(&
m_input_str)->required(), help_str.c_str());
320 (
"input,i", po::value<std::string>(&
m_input_str), help_str.c_str());
328 (
"output,o", po::value<fs::path>(&
m_output_path)->value_name(
ArgHandler::path()),
"Name for output file. Use STDOUT to print results without extra messages.");
334 (
"gzip,z", po::value(&
m_gzip_flag)->zero_tokens(),
"Write gzipped output file.");
339 std::string help_str;
340 help_str =
"Single supercell name to use casm " +
m_tag +
" with, such as 'SCEL4_2_2_1_0_0_0'";
347 std::string help_str;
348 help_str =
"One or more supercells to use casm " +
m_tag +
" with, such as 'SCEL4_2_2_1_0_0_0'";
355 std::string help_str;
357 help_str =
"Single configuration to use casm " +
m_tag +
" with, such as 'SCEL4_2_2_1_0_0_0/3'";
366 std::string help_str;
368 help_str =
"One or more configurations to use casm " +
m_tag +
" with, such as 'SCEL4_2_2_1_0_0_0/3'";
379 (
"coord", po::value<std::string>(&
m_coordtype_str)->default_value(
"frac")->value_name(
ArgHandler::coordtype()),
"Type of coordinate system to use. Use 'frac' for fractional (default) or 'cart' for Cartesian.");
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
std::string m_input_str
The settings path to go with add_input_suboption()
static void operator_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for OPERATOR.
const std::string & coordtype_str() const
Return the coordinate type in the form of a string.
std::vector< std::string > m_help_opt_vec
The list of strings to go with add_general_help_suboption()
std::string m_supercell_str
The string of the supercell name of add_scelname_suboption()
void add_output_suboption()
Add a –output suboption. Expects to allow "STDOUT" to print to screen.
std::vector< std::string > m_config_strs
The list of the supercell names of add_configname_suboption()
void add_verbosity_suboption()
Add a –verbosity suboption. Default "standard" of "none", "quiet", "standard", "verbose", "debug" or an int 0-100.
void add_scelnames_suboption()
Add a –scelnames suboption.
virtual void initialize()=0
Fill in the options descriptions accordingly.
ArgHandler::ARG_TYPE ARG_TYPE
static std::string configname()
Get value_type string for configuration completion.
const fs::path settings_path() const
Returns the path corresponding to add_settings_suboption.
const std::string & config_str() const
Returns the name of the supercell for add_configname_suboption(), for when multiple=false.
void add_help_suboption()
Add a plain –help suboption.
void add_settings_suboption(bool required=true)
Add a –settings suboption. Expects a corresponding casm format to go with it.
void add_configname_suboption()
Add a –configname suboption.
std::string m_config_str
The name of a single configname to go with add_configname_suboption()
void add_general_help_suboption()
Add a smart –help suboption that takes "properties" or "operators".
void add_configlists_nodefault_suboption()
Add –configs suboption (no default)
void add_configlist_suboption(const fs::path &_default="MASTER")
Add –config suboption (defaults to MASTER)
static void query_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for QUERY.
fs::path m_selection_path
The selection string to go with add_config_suboption.
const std::string & verbosity_str() const
Returns the string corresponding to add_verbosity_suboption()
std::string m_tag
name of the casm command
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
static std::string path()
Get value_type string for path completion.
static std::string supercell()
Get value_type string for supercell completion.
void add_input_suboption(bool required=true)
Add a –input suboption. Expects a corresponding casm format to go with it.
void add_configlists_suboption(const fs::path &_default="MASTER")
Add –configs suboption (defaults to MASTER)
static std::string coordtype()
Get value_type string for coordinate mode completion.
static std::string operation()
Get value_type string for operation completion.
std::string input_str() const
Returns the path corresponding to add_input_suboption.
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
const po::options_description & desc()
Get the program options, filled with the initialized values.
po::variables_map m_vm
Boost program options variable map.
static ARG_TYPE determine_type(const po::option_description &boost_option)
Translate the stored boost value_name into an ARG_TYPE for the completer engine.
const std::vector< std::string > & help_opt_vec() const
Returns the list of strings corresponding to add_general_help_suboption()
static std::string command()
Get value_type string for command completion (i.e. stuff in your $PATH)
fs::path m_output_path
The path that goes with add_output_suboption.
static std::string query()
Get value_type string for query completion.
OptionHandlerBase(const std::string &init_option_tag)
Define the name of the command during construction.
static void void_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for VOID (i.e. do nothing) ...
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.
bool gzip_flag() const
Returns the value assigned for add_gzip_suboption()
static void path_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for PATH.
void add_gzip_suboption()
Add a –gzip suboption. The value will default to false unless overridden by the derived class...
const std::string & supercell_str() const
Returns the name of the supercell for add_scelname_suboption()
void add_confignames_suboption()
Add a –confignames suboption.
fs::path m_settings_path
The settings path to go with add_settings_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.
bool m_gzip_flag
The bool that goes with add_gzip_suboption.
po::variables_map & vm()
Get the variables map.
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
const std::string & tag() const
The desired name for the casm option (Perhaps this should get tied with CommandArg?)
std::string m_verbosity_str
The verbosity string to go with add_config_suboption.
static void command_to_bash(std::vector< std::string > &arguments)
Fill the output strings with bash completion appropriate values for COMMAND.
std::string m_coordtype_str
The enum value in the form of a string for add_coordtype_suboption(). Only the first letter matters...
std::vector< std::string > m_supercell_strs
The list of supercell names of add_scelnames_suboption()
const fs::path output_path() const
Returns the path corresponding to add_output_suboption()
static const std::vector< std::pair< std::string, ARG_TYPE > > m_argument_table
List of pairs relating the value type name of po::option_description to its corresponding argument ty...
const_iterator cend() const
std::vector< fs::path > m_selection_paths
The selection string to go with add_config_suboption.
void scelname_to_bash(std::vector< std::string > &arguments)
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()