Bayeux
3.4.1
Core Foundation library for SuperNEMO
|
Command line shell interface. More...
#include <bayeux/datatools/ui/basic_shell.h>
Public Types | |
enum | run_core_flags { RC_NONE = 0, RC_INHIBIT_HISTORY = datatools::bit_mask::bit00, RC_INHIBIT_READLINE = datatools::bit_mask::bit01, RC_EXIT_ON_ERROR = datatools::bit_mask::bit02 } |
Special flags for run core. More... | |
typedef target_command_interface< basic_shell > | shell_command_interface_type |
Public Types inherited from datatools::i_tree_dumpable | |
enum | ostream_type { OSTREAM_COUT = 1, OSTREAM_CERR = 2, OSTREAM_CLOG = 3 } |
Enumeration for standard output streams. More... | |
Public Member Functions | |
basic_shell (const std::string &name_="") | |
Default constructor. More... | |
virtual | ~basic_shell () |
Destructor. More... | |
datatools::logger::priority | get_logging () const |
Return the logging priority threshold. More... | |
void | set_logging (datatools::logger::priority) |
Set the logging priority threshold. More... | |
bool | has_name () const |
Check is the name is set. More... | |
void | set_name (const std::string &) |
Set the name: More... | |
const std::string & | get_name () const |
Return the name. More... | |
bool | has_title () const |
Check is the title is set. More... | |
void | set_title (const std::string &) |
Set the title: More... | |
const std::string & | get_title () const |
Return the title. More... | |
bool | has_version () const |
Check if version identifier is set. More... | |
void | set_version (const ::datatools::version_id &) |
Set the version. More... | |
const ::datatools::version_id & | get_version () const |
Return the version. More... | |
void | set_prompt (const std::string &) |
const std::string & | get_prompt () const |
Return the prompt. More... | |
void | set_continuation_prompt (const std::string &) |
const std::string & | get_continuation_prompt () const |
Return the continuation prompt. More... | |
std::string | get_effective_prompt () const |
Return the current effective prompt. More... | |
std::string | get_effective_continuation_prompt () const |
Return the current effective prompt. More... | |
bool | has_user () const |
Check if the user identifier is set. More... | |
void | set_user (const std::string &) |
Set the user identifier. More... | |
const std::string & | get_user () const |
Return the user identifier. More... | |
bool | has_host () const |
Check if the host identifier is set. More... | |
void | set_host (const std::string &) |
Set the host identifier. More... | |
const std::string & | get_host () const |
Return the host identifier. More... | |
void | set_exit_on_error (bool) |
Set the abort-on-error flag. More... | |
bool | is_exit_on_error () const |
Return the abort-on-error flag. More... | |
void | set_using_splash (bool) |
Set the using splash. More... | |
bool | is_using_splash () const |
Return the using splash flag. More... | |
void | set_using_readline (bool) |
Set the using readline. More... | |
bool | is_using_readline () const |
Return the using readline flag. More... | |
void | set_using_history (bool) |
Set the using history. More... | |
bool | is_using_history () const |
Return the using history flag. More... | |
void | set_history_filename (const std::string &) |
Set the history filename. More... | |
const std::string & | get_history_filename () const |
Return the history filename. More... | |
void | set_history_truncate (unsigned int) |
Set the history truncate. More... | |
unsigned int | get_history_truncate () |
Return the history truncate. More... | |
void | set_history_add_only_on_success (bool) |
Set the flag to add only valid command line in history. More... | |
bool | is_history_add_only_on_success () const |
Return the flag to add only valid command line in history. More... | |
bool | has_default_path () const |
Check if the default path is set. More... | |
void | set_default_path (const std::string &) |
Set the default path. More... | |
const std::string & | get_default_path () const |
Return the default path. More... | |
bool | has_current_path () const |
Check if the current path is set. More... | |
void | set_current_path (const std::string &p_) |
Set the current path. More... | |
const std::string & | get_current_path () const |
Return the current path. More... | |
bool | has_services () const |
Check if services are defined. More... | |
void | set_services (::datatools::service_manager &services_) |
Set the handle to an external service manager. More... | |
::datatools::service_manager & | grab_services () |
Return a mutable reference to the service manager. More... | |
const ::datatools::service_manager & | get_services () const |
Return a non mutable reference to the service manager. More... | |
void | reset_services () |
Reset the handle. More... | |
bool | has_ihs () const |
Check if IHS is set. More... | |
void | set_ihs (ihs &ihs_) |
Set the handle to an external IHS. More... | |
ihs & | grab_ihs () |
Return a mutable reference to the IHS. More... | |
const ihs & | get_ihs () const |
Return a non mutable reference to the IHS. More... | |
void | builtin_command_names (std::vector< std::string > &cmd_names_) const |
Build the list of builtin commands. More... | |
bool | has_builtin_command (const std::string &cmd_name_) const |
Check if a builtin command is available. More... | |
const base_command & | get_builtin_command (const std::string &cmd_name_) const |
Return a const reference to a builtin command. More... | |
bool | is_initialized () const |
Check initialization. More... | |
void | initialize_simple () |
Initialization. More... | |
void | initialize (const datatools::properties &) |
Initialization. More... | |
void | reset () |
Reset. More... | |
int | run (std::istream *in_=nullptr) |
Main run loop. More... | |
std::string | canonical_path (const std::string &path_) const |
Build the canonical full path associated to a given relative or absolute path. More... | |
bool | is_absolute_path (const std::string &path_) const |
Check if a path is an absolute existing path. More... | |
bool | is_stop_requested () const |
Check if stop is requested. More... | |
void | set_stop_requested () |
Set the stop requested flag. More... | |
void | load_macro (const std::string ¯o_, uint32_t flags_=0) |
Load a macro file. More... | |
void | build_current_list_of_interfaces (std::vector< std::string > &names_, uint32_t flags_=0, std::size_t depth_=0) const |
Build list of interfaces. More... | |
bool | has_system_interface () const |
Check if system interface is set. More... | |
void | set_system_interface (shell_command_interface_type &) |
Set an external system interface. More... | |
virtual void | print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=datatools::i_tree_dumpable::empty_options()) const |
Public Member Functions inherited from datatools::i_tree_dumpable | |
i_tree_dumpable () | |
Constructor. More... | |
virtual | ~i_tree_dumpable () |
Destructor. More... | |
virtual void | tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const |
Main old interface method for printing. More... | |
void | print_tree_json (std::ostream &out_=std::clog, const std::string &json_options_="") const |
Printing with jsonized options. More... | |
void | print_tree_json (std::ostream &out_=std::clog, const char *json_options_=nullptr) const |
Printing with jsonized options. More... | |
void | tree_dump_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="", const bool inherit_=false) const |
void | tree_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="") const |
void | smart_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="") const |
Static Public Member Functions | |
static const std::string & | system_interface_name () |
Retour the name of the builtin system interface. More... | |
static const std::string & | default_prompt () |
Retour the default prompt. More... | |
static const std::string & | default_continuation_prompt () |
Retour the default continuation prompt. More... | |
static void | make_title_upper (const std::string &title_, std::string &upper_) |
Build a upper and spaced title. More... | |
Static Public Member Functions inherited from datatools::i_tree_dumpable | |
static const boost::property_tree::ptree & | empty_options () |
static boost::property_tree::ptree | make_base_print_options (const std::string &title_, const std::string &indent_="", const bool inherit_=false) |
static std::ostream & | last_skip_tag (std::ostream &out_) |
static std::ostream & | skip_tag (std::ostream &out_) |
static std::ostream & | last_tag (std::ostream &out_) |
static std::ostream & | tag (std::ostream &out_) |
Static Public Attributes | |
static const unsigned int | DEFAULT_HISTORY_TRUNCATE = 200 |
Protected Member Functions | |
void | _set_defaults () |
Set default values to attributes. More... | |
void | _expand_prompt (const std::string &, std::string &) const |
Update the effective prompt. More... | |
void | _print_splash (std::ostream &out_=std::cout) |
Print the splash screen. More... | |
void | _print_help (std::ostream &out_=std::cout) |
Print online help. More... | |
virtual void | _at_init (const datatools::properties &config_) |
At initialization. More... | |
virtual void | _at_reset () |
At reset. More... | |
virtual void | _at_run_start () |
At run start. More... | |
datatools::command::returned_info | _run_core (std::istream *in_=nullptr, uint32_t flags_=RC_NONE) |
At run loop. More... | |
datatools::command::returned_info | _run_command (const std::string &command_line_) |
Run command. More... | |
virtual void | _at_run_stop () |
At run stop. More... | |
shell_command_interface_type & | _grab_system_interface () |
Return the system interface. More... | |
const shell_command_interface_type & | _get_system_interface () const |
Return the system interface. More... | |
virtual bool | _compute_continue_condition () |
Command line shell interface.
typedef target_command_interface<basic_shell> datatools::ui::basic_shell::shell_command_interface_type |
datatools::ui::basic_shell::basic_shell | ( | const std::string & | name_ = "" | ) |
Default constructor.
|
virtual |
Destructor.
|
protectedvirtual |
At initialization.
|
protectedvirtual |
At reset.
|
protectedvirtual |
At run start.
|
protectedvirtual |
At run stop.
|
protectedvirtual |
Compute continuation condition
|
protected |
Update the effective prompt.
|
protected |
Return the system interface.
|
protected |
Return the system interface.
|
protected |
Print online help.
|
protected |
Print the splash screen.
|
protected |
Run command.
|
protected |
At run loop.
|
protected |
Set default values to attributes.
void datatools::ui::basic_shell::build_current_list_of_interfaces | ( | std::vector< std::string > & | names_, |
uint32_t | flags_ = 0 , |
||
std::size_t | depth_ = 0 |
||
) | const |
Build list of interfaces.
void datatools::ui::basic_shell::builtin_command_names | ( | std::vector< std::string > & | cmd_names_ | ) | const |
Build the list of builtin commands.
std::string datatools::ui::basic_shell::canonical_path | ( | const std::string & | path_ | ) | const |
Build the canonical full path associated to a given relative or absolute path.
|
static |
Retour the default continuation prompt.
|
static |
Retour the default prompt.
const base_command& datatools::ui::basic_shell::get_builtin_command | ( | const std::string & | cmd_name_ | ) | const |
Return a const reference to a builtin command.
const std::string& datatools::ui::basic_shell::get_continuation_prompt | ( | ) | const |
Return the continuation prompt.
const std::string& datatools::ui::basic_shell::get_current_path | ( | ) | const |
Return the current path.
const std::string& datatools::ui::basic_shell::get_default_path | ( | ) | const |
Return the default path.
std::string datatools::ui::basic_shell::get_effective_continuation_prompt | ( | ) | const |
Return the current effective prompt.
std::string datatools::ui::basic_shell::get_effective_prompt | ( | ) | const |
Return the current effective prompt.
const std::string& datatools::ui::basic_shell::get_history_filename | ( | ) | const |
Return the history filename.
unsigned int datatools::ui::basic_shell::get_history_truncate | ( | ) |
Return the history truncate.
const std::string& datatools::ui::basic_shell::get_host | ( | ) | const |
Return the host identifier.
datatools::logger::priority datatools::ui::basic_shell::get_logging | ( | ) | const |
Return the logging priority threshold.
const std::string& datatools::ui::basic_shell::get_name | ( | ) | const |
Return the name.
const std::string& datatools::ui::basic_shell::get_prompt | ( | ) | const |
Return the prompt.
const ::datatools::service_manager& datatools::ui::basic_shell::get_services | ( | ) | const |
Return a non mutable reference to the service manager.
const std::string& datatools::ui::basic_shell::get_title | ( | ) | const |
Return the title.
const std::string& datatools::ui::basic_shell::get_user | ( | ) | const |
Return the user identifier.
const ::datatools::version_id& datatools::ui::basic_shell::get_version | ( | ) | const |
Return the version.
ihs& datatools::ui::basic_shell::grab_ihs | ( | ) |
Return a mutable reference to the IHS.
::datatools::service_manager& datatools::ui::basic_shell::grab_services | ( | ) |
Return a mutable reference to the service manager.
bool datatools::ui::basic_shell::has_builtin_command | ( | const std::string & | cmd_name_ | ) | const |
Check if a builtin command is available.
bool datatools::ui::basic_shell::has_current_path | ( | ) | const |
Check if the current path is set.
bool datatools::ui::basic_shell::has_default_path | ( | ) | const |
Check if the default path is set.
bool datatools::ui::basic_shell::has_host | ( | ) | const |
Check if the host identifier is set.
bool datatools::ui::basic_shell::has_ihs | ( | ) | const |
Check if IHS is set.
bool datatools::ui::basic_shell::has_name | ( | ) | const |
Check is the name is set.
bool datatools::ui::basic_shell::has_services | ( | ) | const |
Check if services are defined.
bool datatools::ui::basic_shell::has_system_interface | ( | ) | const |
Check if system interface is set.
bool datatools::ui::basic_shell::has_title | ( | ) | const |
Check is the title is set.
bool datatools::ui::basic_shell::has_user | ( | ) | const |
Check if the user identifier is set.
bool datatools::ui::basic_shell::has_version | ( | ) | const |
Check if version identifier is set.
void datatools::ui::basic_shell::initialize | ( | const datatools::properties & | ) |
Initialization.
void datatools::ui::basic_shell::initialize_simple | ( | ) |
Initialization.
bool datatools::ui::basic_shell::is_absolute_path | ( | const std::string & | path_ | ) | const |
Check if a path is an absolute existing path.
bool datatools::ui::basic_shell::is_exit_on_error | ( | ) | const |
Return the abort-on-error flag.
bool datatools::ui::basic_shell::is_history_add_only_on_success | ( | ) | const |
Return the flag to add only valid command line in history.
bool datatools::ui::basic_shell::is_initialized | ( | ) | const |
Check initialization.
bool datatools::ui::basic_shell::is_stop_requested | ( | ) | const |
Check if stop is requested.
bool datatools::ui::basic_shell::is_using_history | ( | ) | const |
Return the using history flag.
bool datatools::ui::basic_shell::is_using_readline | ( | ) | const |
Return the using readline flag.
bool datatools::ui::basic_shell::is_using_splash | ( | ) | const |
Return the using splash flag.
void datatools::ui::basic_shell::load_macro | ( | const std::string & | macro_, |
uint32_t | flags_ = 0 |
||
) |
Load a macro file.
|
static |
Build a upper and spaced title.
|
virtual |
Smart print
Supported options:
Reimplemented from datatools::i_tree_dumpable.
void datatools::ui::basic_shell::reset | ( | ) |
Reset.
void datatools::ui::basic_shell::reset_services | ( | ) |
Reset the handle.
int datatools::ui::basic_shell::run | ( | std::istream * | in_ = nullptr | ) |
Main run loop.
void datatools::ui::basic_shell::set_continuation_prompt | ( | const std::string & | ) |
Set the continuation prompt
void datatools::ui::basic_shell::set_current_path | ( | const std::string & | p_ | ) |
Set the current path.
void datatools::ui::basic_shell::set_default_path | ( | const std::string & | ) |
Set the default path.
void datatools::ui::basic_shell::set_exit_on_error | ( | bool | ) |
Set the abort-on-error flag.
void datatools::ui::basic_shell::set_history_add_only_on_success | ( | bool | ) |
Set the flag to add only valid command line in history.
void datatools::ui::basic_shell::set_history_filename | ( | const std::string & | ) |
Set the history filename.
void datatools::ui::basic_shell::set_history_truncate | ( | unsigned int | ) |
Set the history truncate.
void datatools::ui::basic_shell::set_host | ( | const std::string & | ) |
Set the host identifier.
void datatools::ui::basic_shell::set_ihs | ( | ihs & | ihs_ | ) |
Set the handle to an external IHS.
void datatools::ui::basic_shell::set_logging | ( | datatools::logger::priority | ) |
Set the logging priority threshold.
void datatools::ui::basic_shell::set_name | ( | const std::string & | ) |
Set the name:
void datatools::ui::basic_shell::set_prompt | ( | const std::string & | ) |
Set the prompt
Supported syntax: n is replaced by the name of the shell w is replaced by the current working interface path W is replaced by the basename of the current working interface path
Example:
void datatools::ui::basic_shell::set_services | ( | ::datatools::service_manager & | services_ | ) |
Set the handle to an external service manager.
void datatools::ui::basic_shell::set_stop_requested | ( | ) |
Set the stop requested flag.
void datatools::ui::basic_shell::set_system_interface | ( | shell_command_interface_type & | ) |
Set an external system interface.
void datatools::ui::basic_shell::set_title | ( | const std::string & | ) |
Set the title:
void datatools::ui::basic_shell::set_user | ( | const std::string & | ) |
Set the user identifier.
void datatools::ui::basic_shell::set_using_history | ( | bool | ) |
Set the using history.
void datatools::ui::basic_shell::set_using_readline | ( | bool | ) |
Set the using readline.
void datatools::ui::basic_shell::set_using_splash | ( | bool | ) |
Set the using splash.
void datatools::ui::basic_shell::set_version | ( | const ::datatools::version_id & | ) |
Set the version.
|
static |
Retour the name of the builtin system interface.
|
static |