47 extern std::string
NAME;
56 extern const char*
const*
argv;
84 for (
const char*
const* p = text; *p; ++p)
89 std::string
syntax (
int format)
const;
98 const std::string&
code,
105 operator std::string ()
const;
142 push_back (option_group);
174 throw Exception (
"output file \"" +
name +
"\" already exists (use -force option to force overwrite)");
211 operator std::string ()
const {
return p; }
220 assert (arg->
type == IntSeq);
221 try {
return parse_ints<int32_t> (p); }
227 assert (arg->
type == IntSeq);
228 try {
return parse_ints<uint32_t> (p); }
234 assert (arg->
type == FloatSeq);
241 operator int ()
const {
return as_int(); }
242 operator unsigned int ()
const {
return as_uint(); }
243 operator long int ()
const {
return as_int(); }
244 operator long unsigned int ()
const {
return as_uint(); }
245 operator long long int ()
const {
return as_int(); }
246 operator long long unsigned int ()
const {
return as_uint(); }
253 const char*
c_str ()
const {
return p; }
266 std::string msg (
"error parsing token \"");
268 if (opt) msg += std::string (
"\" for option \"") + opt->
id +
"\"";
269 else msg += std::string (
"\" for argument \"") + arg->
id +
"\"";
291 for (
size_t i = 0; i !=
option->size(); ++i) {
292 const char* p = arguments[i];
295 if (( (*
option)[i].type == ImageIn || (*
option)[i].type == ImageOut ) &&
is_dash (arguments[i]))
297 if ((*
option)[i].type == Integer || (*
option)[i].type == Float || (*
option)[i].type == IntSeq ||
298 (*
option)[i].type == FloatSeq || (*
option)[i].type == Various)
300 WARN (std::string(
"Value \"") + arguments[i] +
"\" is being used as " +
302 "the expected argument " :
303 (
"one of the " +
str(
option->size()) +
" expected arguments ")) +
304 "for option \"-" +
option->id +
"\", yet this itself looks like a separate command-line option; " +
305 "the requisite input" +
306 ((
option->size() == 1) ?
" " :
"s ") +
307 "to command-line option \"-" +
option->id +
"\" may have been erroneously omitted, which may cause " +
308 "other command-line parsing errors");
318 assert (num < opt->size());
414 extern const char*
AUTHOR;
464 template <
typename T>
468 T r = (opt.size()) ? opt[0][0] : default_value;
476 std::string retval (left);
477 retval += std::string (right);
484 stream << std::string (arg);
A class to specify a command-line argument.
ArgType type
the argument type
const char * id
the argument name
a class to hold the list of Argument's
ArgumentList & operator+(const Argument &argument)
std::string syntax(int format) const
vector of strings to hold more comprehensive command description
Description & operator+(const char *text)
std::string syntax(int format) const
object for storing a single example command usage
const std::string description
std::string syntax(int format) const
Example(const std::string &title, const std::string &code, const std::string &description)
a class to hold the list of Example's
ExampleList & operator+(const Example &example)
std::string syntax(int format) const
a class to hold a named list of Option's
A class to specify a command-line option.
const char * id
the option name
a class to hold the list of option groups
OptionList & operator+(const OptionGroup &option_group)
std::string syntax(int format) const
const char * c_str() const
vector< uint32_t > as_sequence_uint() const
default_type as_float() const
vector< default_type > as_sequence_float() const
vector< int32_t > as_sequence_int() const
const char * as_text() const
object storing information about option parsed from command-line
const char *const * args
pointer into argv corresponding to the option's first argument
bool operator==(const char *match) const
check whether this option matches the name supplied
const ParsedArgument operator[](size_t num) const
const Option * opt
reference to the corresponding Option entry in the OPTIONS section
ParsedOption(const Option *option, const char *const *arguments)
std::string full_usage()
dump formatted help page [used internally]
void verify_usage()
verify that command's usage() function has set requisite fields [used internally]
const vector< ParsedOption > get_options(const std::string &name)
return all command-line options matching name
void init(int argc, const char *const *argv)
initialise MRtrix and parse command-line arguments
std::ostream & operator<<(std::ostream &stream, const App::ParsedArgument &arg)
void check_overwrite(const std::string &name)
std::string operator+(const char *left, const App::ParsedArgument &right)
convenience function provided mostly to ease writing Exception strings
OptionList OPTIONS
the options accepted by the command
ExampleList EXAMPLES
example usages of the command
const char * mrtrix_version
vector< ParsedArgument > argument
the list of arguments parsed from the command-line
const char * AUTHOR
set the author of the command
std::string help_synopsis(int format)
const char * COPYRIGHT
set the copyright notice if different from that used in MRtrix
const char * argtype_description(ArgType type)
void parse_special_options()
option parsing that should happen before GUI creation [used internally]
const char * SYNOPSIS
set a one-sentence synopsis for the command
std::string usage_syntax(int format)
T get_option_value(const std::string &name, const T default_value)
Returns the option value if set, and the default otherwise.
Description DESCRIPTION
additional description of the command over and above the synopsis
std::string help_head(int format)
void(* check_overwrite_files_func)(const std::string &name)
const char * project_version
Description REFERENCES
add references to command help page
std::string command_history_string
const std::thread::id main_thread_ID
const char * project_build_date
bool REQUIRES_AT_LEAST_ONE_ARGUMENT
set to false if command can operate with no arguments
const Option * match_option(const char *stub)
uniquely match option stub to Option
void sort_arguments(int argc, const char *const *argv)
sort command-line tokens into arguments and options [used internally]
std::string help_tail(int format)
ArgumentList ARGUMENTS
the arguments expected by the command
void parse()
do the actual parsing of the command-line [used internally]
OptionGroup __standard_options
the group of standard options for all commands
vector< ParsedOption > option
the list of options parsed from the command-line
bool exists(const std::string &path)
bool consume_dash(const char *&arg)
match current character to a dash or any Unicode character that looks like one
vector< default_type > parse_floats(const std::string &spec)
double default_type
the default type used throughout MRtrix
bool match(const std::string &pattern, const std::string &text, bool ignore_case=false)
bool to< bool >(const std::string &string)
std::string str(const T &value, int precision=0)
std::string lowercase(const std::string &string)
return lowercase version of string
size_t is_dash(const std::string &arg)
match whole string to a dash or any Unicode character that looks like one