ChainCLI
A modern C++20 command-line interface library
Loading...
Searching...
No Matches
cli::CliApp Class Reference

Main class representing a command-line application. More...

#include <cli_app.h>

Public Member Functions

 CliApp (const CliApp &)=delete
 
CliAppoperator= (const CliApp &)=delete
 
 CliApp (std::string_view executableName)
 
 CliApp (CliConfig &&config)
 
 CliApp (const CliConfig &config, std::unique_ptr< logging::AbstractLogger > logger)
 
CliAppwithCommand (std::unique_ptr< commands::Command > subCommandPtr)
 Add a new command to the application.
 
CliAppwithCommand (commands::Command &&subCommand)
 Add a new command to the application.
 
void init ()
 Initialize the CLI application, preparing it for execution This method sets up internal structures and should be called before run() if any commands have been added. If not called explicitly, it will be called automatically on the first invocation of run().
 
int run (int argc, char *argv[])
 Run the CLI application with the given arguments.
 
logging::AbstractLoggerLogger ()
 Get the logger instance used by the CLI application.
 
const commands::CommandTreegetCommandTree () const
 Get the command tree used by the CLI application.
 
commands::CommandgetMainCommand ()
 Get the command tree used by the CLI application.
 
CliConfiggetConfig ()
 Get the configuration used by the CLI application.
 
commands::docwriting::DocWritergetDocWriter ()
 Get the documentation writer used by the CLI application.
 
void setLogger (std::unique_ptr< logging::Logger > &&newLogger)
 Set the logger instance used by the CLI application.
 

Detailed Description

Main class representing a command-line application.

Member Function Documentation

◆ getCommandTree()

const commands::CommandTree & cli::CliApp::getCommandTree ( ) const
inline

Get the command tree used by the CLI application.

Returns
a reference to the command tree

◆ getConfig()

CliConfig & cli::CliApp::getConfig ( )
inline

Get the configuration used by the CLI application.

Returns
a reference to the configuration

◆ getDocWriter()

commands::docwriting::DocWriter & cli::CliApp::getDocWriter ( )
inline

Get the documentation writer used by the CLI application.

Returns
a reference to the documentation writer

◆ getMainCommand()

commands::Command * cli::CliApp::getMainCommand ( )
inline

Get the command tree used by the CLI application.

Returns
a reference to the command tree

◆ Logger()

logging::AbstractLogger & cli::CliApp::Logger ( )
inline

Get the logger instance used by the CLI application.

Returns
a reference to the logger instance

◆ run()

inline_t int cli::CliApp::run ( int  argc,
char *  argv[] 
)

Run the CLI application with the given arguments.

Parameters
argcthe argument count
argvthe argument vector
Returns
the exit code of the application

◆ setLogger()

void cli::CliApp::setLogger ( std::unique_ptr< logging::Logger > &&  newLogger)
inline

Set the logger instance used by the CLI application.

Parameters
newLoggerthe new logger instance

◆ withCommand() [1/2]

inline_t CliApp & cli::CliApp::withCommand ( commands::Command &&  subCommand)

Add a new command to the application.

Parameters
subCommandthe command to add
Returns
a reference to this CliApp instance

◆ withCommand() [2/2]

inline_t CliApp & cli::CliApp::withCommand ( std::unique_ptr< commands::Command subCommandPtr)

Add a new command to the application.

Parameters
subCommandPtrthe unique pointer to the command to add
Returns
a reference to this CliApp instance

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