CASM
AClustersApproachtoStatisticalMechanics
|
#include <Complete.hh>
A typical casm command takes 3 types of arguments: Option: Things like "super", "enum", "monte", etc Suboption: Anything that starts with "--" or "-", such as "--max" or "-z" Argument: The argument you pass to the suboption, such as an integer or filename
The Engine class contains all the information you need to pass to a bash completion script. However, it is currently limited to some specific kind of formatting. Boost program option can do a bunch of fancy things, but we don't seem to be using them much, so the completer is currently limited to expecting only –long and -s(hort) (single character!) options.
Definition at line 146 of file Complete.hh.
Public Member Functions | |
Engine () | |
Default constructor so you can push back your own things. More... | |
Engine (const std::vector< Option > &init_options) | |
Construct by passing list of options. More... | |
std::vector< std::string > | probe_options () const |
Construct by passing boost program options (eventually preferred so that it can update itself) More... | |
std::vector< std::string > | probe_suboptions (const std::string &option_tag) const |
For a particular option, get the available suboptions. More... | |
std::vector< std::string > | probe_arguments (const std::string &option_tag, const std::string &suboption_tag) const |
Return the arguments that should be bash completed. More... | |
void | push_back (const Option &new_option) |
Guess what should be returned based on the current word (probably not gonna make it that smart) More... | |
Private Types | |
typedef std::size_t | size_type |
typedef ArgHandler::ARG_TYPE | ARG_TYPE |
Private Member Functions | |
ARG_TYPE | _probe_argument_type (const std::string &option_tag, const std::string &suboption_tag) const |
For a particular option with suboption, get what kind of arguments are expected. More... | |
Private Attributes | |
std::vector< Option > | m_avail_options |
List of all the available (presumably casm) options (e.g. "monte", "init", etc) More... | |
|
private |
Definition at line 148 of file Complete.hh.
|
private |
Definition at line 147 of file Complete.hh.
|
inline |
Default constructor so you can push back your own things.
Definition at line 153 of file Complete.hh.
CASM::Completer::Engine::Engine | ( | const std::vector< Option > & | init_options | ) |
Construct by passing list of options.
Definition at line 150 of file Complete.cc.
|
private |
For a particular option with suboption, get what kind of arguments are expected.
First run through all the Options and see if you can find one that matches the provided option_tag. If one is found, then run through all the available Suboptions of said tag and see if the provided Suboption_tag can be matched. If it can be matched, return the expected argument type of that Suboption.
If either tag can't be found the routine returns VOID, i.e. bash completion shouldn't make any suggestions.
Definition at line 253 of file Complete.cc.
std::vector< std::string > CASM::Completer::Engine::probe_arguments | ( | const std::string & | option_tag, |
const std::string & | suboption_tag | ||
) | const |
Return the arguments that should be bash completed.
Determine what kind of argument should follow the provided suboption and return either a bash completion suggestion, or a keyword the bash completion script can identify to make the completion itself (e.g. completing paths or available executables)
Definition at line 191 of file Complete.cc.
std::vector< std::string > CASM::Completer::Engine::probe_options | ( | ) | const |
Construct by passing boost program options (eventually preferred so that it can update itself)
Get a list of all available options
Runs through all the available Options and generates a list of all their tags. This list is then returned.
Definition at line 159 of file Complete.cc.
std::vector< std::string > CASM::Completer::Engine::probe_suboptions | ( | const std::string & | option_tag | ) | const |
For a particular option, get the available suboptions.
Run through all the Options and try to match the provided option_tag. If one of the Options has that tag, then return all the Suboptions it has as a list of –long formatted strings. If the proved tag doesn't match any options, return an empty list.
Definition at line 174 of file Complete.cc.
void CASM::Completer::Engine::push_back | ( | const Option & | new_option | ) |
Guess what should be returned based on the current word (probably not gonna make it that smart)
Append a new option to the engine
Definition at line 263 of file Complete.cc.
|
private |
List of all the available (presumably casm) options (e.g. "monte", "init", etc)
Definition at line 179 of file Complete.hh.