CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
CASM::Completer::ArgHandler Class Reference

#include <Handlers.hh>

Detailed Description

Handle the value type names of po::option_description. This class determines what the keywords mean, and translates them into the ARG_TYPE enum as appropriate.

If you want bash completion for your boost program options, never specify option_description::value_name manually (e.g. raw string), always request the string through this class.

When the Engine class isn't returning strings corresponding to options or suboptions that bash should complete, then the user is in the process of writing out an argument. By printing out keywords, the bash completer script can know what kind of arguments are needed for the casm command:

VOID: Don't complete anything PATH: Suggest path completions to a file or directory COMMAND: Suggest executables within the environment PATH SCELNAME: Run through the PrimClex and suggest the enumerated supercell names QUERY: Suggest the available query options OPERATORS: Suggest the available operators casm knows how to use (TODO: This one might be tricky to implement)

Definition at line 34 of file Handlers.hh.

Public Types

enum  ARG_TYPE {
  VOID, PATH, COMMAND, SCELNAME,
  QUERY, OPERATOR, CONFIGNAME, COORDTYPE
}
 

Static Public Member Functions

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. More...
 
static std::string path ()
 Get value_type string for path completion. More...
 
static std::string command ()
 Get value_type string for command completion (i.e. stuff in your $PATH) More...
 
static std::string supercell ()
 Get value_type string for supercell completion. More...
 
static std::string query ()
 Get value_type string for query completion. More...
 
static std::string operation ()
 Get value_type string for operation completion. More...
 
static std::string configname ()
 Get value_type string for configuration completion. More...
 
static std::string coordtype ()
 Get value_type string for coordinate mode completion. More...
 
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) More...
 
static void path_to_bash (std::vector< std::string > &arguments)
 Fill the output strings with bash completion appropriate values for PATH. More...
 
static void command_to_bash (std::vector< std::string > &arguments)
 Fill the output strings with bash completion appropriate values for COMMAND. More...
 
static void scelname_to_bash (std::vector< std::string > &arguments)
 Fill the output strings with bash completion appropriate values for SCELNAME TODO: This routine is currently unimplemented. More...
 
static void query_to_bash (std::vector< std::string > &arguments)
 Fill the output strings with bash completion appropriate values for QUERY. More...
 
static void operator_to_bash (std::vector< std::string > &arguments)
 Fill the output strings with bash completion appropriate values for OPERATOR. More...
 

Static Private Attributes

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 type. More...
 

Member Enumeration Documentation

Enumerator
VOID 
PATH 
COMMAND 
SCELNAME 
QUERY 
OPERATOR 
CONFIGNAME 
COORDTYPE 

Definition at line 37 of file Handlers.hh.

Member Function Documentation

std::string CASM::Completer::ArgHandler::command ( )
static

Get value_type string for command completion (i.e. stuff in your $PATH)

Definition at line 43 of file Handlers.cc.

void CASM::Completer::ArgHandler::command_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for COMMAND.

Definition at line 77 of file Handlers.cc.

std::string CASM::Completer::ArgHandler::configname ( )
static

Get value_type string for configuration completion.

Definition at line 59 of file Handlers.cc.

std::string CASM::Completer::ArgHandler::coordtype ( )
static

Get value_type string for coordinate mode completion.

Definition at line 63 of file Handlers.cc.

ARG_TYPE CASM::Completer::ArgHandler::determine_type ( const po::option_description &  boost_option)
static

Translate the stored boost value_name into an ARG_TYPE for the completer engine.

Definition at line 13 of file Handlers.cc.

std::string CASM::Completer::ArgHandler::operation ( )
static

Get value_type string for operation completion.

Definition at line 55 of file Handlers.cc.

void CASM::Completer::ArgHandler::operator_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for OPERATOR.

Definition at line 97 of file Handlers.cc.

std::string CASM::Completer::ArgHandler::path ( )
static

Get value_type string for path completion.

Definition at line 39 of file Handlers.cc.

void CASM::Completer::ArgHandler::path_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for PATH.

Definition at line 72 of file Handlers.cc.

std::string CASM::Completer::ArgHandler::query ( )
static

Get value_type string for query completion.

Definition at line 51 of file Handlers.cc.

void CASM::Completer::ArgHandler::query_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for QUERY.

Definition at line 86 of file Handlers.cc.

static void CASM::Completer::ArgHandler::scelname_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for SCELNAME TODO: This routine is currently unimplemented.

std::string CASM::Completer::ArgHandler::supercell ( )
static

Get value_type string for supercell completion.

Definition at line 47 of file Handlers.cc.

void CASM::Completer::ArgHandler::void_to_bash ( std::vector< std::string > &  arguments)
static

Fill the output strings with bash completion appropriate values for VOID (i.e. do nothing)

Definition at line 68 of file Handlers.cc.

Member Data Documentation

const std::vector< std::pair< std::string, ARG_TYPE > > CASM::Completer::ArgHandler::m_argument_table
staticprivate

List of pairs relating the value type name of po::option_description to its corresponding argument type.

This construction right here determines what the value_name of the boost options should be named. It is through these strings that bash completion can know which types of completions to suggest.

Definition at line 86 of file Handlers.hh.


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