CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::Completer::Engine Class Reference

#include <Complete.hh>

Detailed Description

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 151 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
 Get a list of all available options. 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)
 Append a new option to the engine. 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
 

Private Attributes

std::vector< Optionm_avail_options
 

Member Typedef Documentation

◆ ARG_TYPE

Definition at line 153 of file Complete.hh.

◆ size_type

typedef std::size_t CASM::Completer::Engine::size_type
private

Definition at line 152 of file Complete.hh.

Constructor & Destructor Documentation

◆ Engine() [1/2]

CASM::Completer::Engine::Engine ( )
inline

Default constructor so you can push back your own things.

Definition at line 157 of file Complete.hh.

◆ Engine() [2/2]

CASM::Completer::Engine::Engine ( const std::vector< Option > &  init_options)

Construct by passing list of options.

Definition at line 154 of file Complete.cc.

Member Function Documentation

◆ _probe_argument_type()

ARG_TYPE CASM::Completer::Engine::_probe_argument_type ( const std::string &  option_tag,
const std::string &  suboption_tag 
) const
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 299 of file Complete.cc.

◆ probe_arguments()

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 197 of file Complete.cc.

◆ probe_options()

std::vector< std::string > CASM::Completer::Engine::probe_options ( ) const

Get a list of all available options.

Construct by passing boost program options (eventually preferred so that it can update itself)

Runs through all the available Options and generates a list of all their tags. This list is then returned.

Definition at line 162 of file Complete.cc.

◆ probe_suboptions()

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 178 of file Complete.cc.

◆ push_back()

void CASM::Completer::Engine::push_back ( const Option new_option)

Append a new option to the engine.

Guess what should be returned based on the current word (probably not gonna make it that smart)

Definition at line 310 of file Complete.cc.

Member Data Documentation

◆ m_avail_options

std::vector<Option> CASM::Completer::Engine::m_avail_options
private

List of all the available (presumably casm) options (e.g. "monte", "init", etc)

Definition at line 188 of file Complete.hh.


The documentation for this class was generated from the following files: