AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::cli Namespace Reference

AnCH command line interface library namespace. More...

Classes

struct  App
 Application summary. More...
struct  Arg
 Argument. More...
class  ArgHandler
 CLI arguments handler. More...
struct  Formatter
 Console formatter. More...

Typedefs

using BindArg = std::function<void(const std::string&)>

Enumerations

enum class  Color {
  BLACK = 0 , RED = 1 , GREEN = 2 , YELLOW = 3 ,
  BLUE = 4 , MAGENTA = 5 , CYAN = 6 , WHITE = 7 ,
  DEFAULT = 9
}

Functions

std::ostream & operator<< (std::ostream &stream, const anch::cli::Formatter &fmt)
BindArg bindTrue (bool &dest)
BindArg bindFalse (bool &dest)
BindArg bindNum (uint16_t &dest)
BindArg bindNum (uint32_t &dest)
BindArg bindNum (uint64_t &dest)
BindArg bindNum (int16_t &dest)
BindArg bindNum (int32_t &dest)
BindArg bindNum (int64_t &dest)
BindArg bindNum (float &dest)
BindArg bindNum (double &dest)
BindArg bindStr (std::string &dest)
BindArg bindStr (std::optional< std::string > &dest)
BindArg bindCol (std::vector< std::string > &dest)
BindArg bindCol (std::list< std::string > &dest)
BindArg bindCol (std::set< std::string > &dest)
BindArg bindPath (std::filesystem::path &dest)
BindArg bindIFS (std::shared_ptr< std::istream > &dest)
BindArg bindOFS (std::shared_ptr< std::ostream > &dest)
BindArg bindOFS (std::shared_ptr< std::ofstream > &dest, std::ios_base::openmode mode=std::ios_base::out)
std::function< void(std::istream &)> bindPipe (std::shared_ptr< std::istream > &dest)
std::function< void(std::ostream &)> bindCout (std::shared_ptr< std::ostream > &dest)
void manageEnvNoFormat ()

Variables

anch::cli::Formatter BOLD
anch::cli::Formatter UNBOLD
anch::cli::Formatter UNDERLINE
anch::cli::Formatter UNUNDERLINE
anch::cli::Formatter BLINK
anch::cli::Formatter UNBLINK
anch::cli::Formatter RESET

Detailed Description

AnCH command line interface library namespace.

Arguments parsing and terminal output formatting. See AnCH CLI library documentation.

Typedef Documentation

◆ BindArg

using anch::cli::BindArg = std::function<void(const std::string&)>

Binding function alias

Enumeration Type Documentation

◆ Color

enum class anch::cli::Color
strong

Console color definition

Author
Vincent Lachenal
Enumerator
BLACK 

Black

RED 

Red

GREEN 

Green

YELLOW 

Yellow

BLUE 

Blue

MAGENTA 

Magenta

CYAN 

Cyan

WHITE 

White

DEFAULT 

Default color console

Function Documentation

◆ bindCol() [1/3]

BindArg anch::cli::bindCol ( std::list< std::string > & dest)

Add value to list

Parameters
destthe sdt::list to fill
Returns
the binding function
Here is the call graph for this function:

◆ bindCol() [2/3]

BindArg anch::cli::bindCol ( std::set< std::string > & dest)

Add value to set

Parameters
destthe sdt::set to fill
Returns
the binding function
Here is the call graph for this function:

◆ bindCol() [3/3]

BindArg anch::cli::bindCol ( std::vector< std::string > & dest)

Add value to vector

Parameters
destthe std::vector to fill
Returns
the binding function
Here is the call graph for this function:

◆ bindCout()

std::function< void(std::ostream &)> anch::cli::bindCout ( std::shared_ptr< std::ostream > & dest)

Bind std::cout to output stream

Parameters
destthe destination output stream
Here is the call graph for this function:

◆ bindFalse()

BindArg anch::cli::bindFalse ( bool & dest)

Bind false utility function

Parameters
destthe bool to set
Returns
the binding function
Here is the call graph for this function:

◆ bindIFS()

BindArg anch::cli::bindIFS ( std::shared_ptr< std::istream > & dest)

Bind input file stream

Parameters
destthe std::istream to fill
Returns
the binding function (which raises std::invalid_argument when file does not exist, is not a regular file or can not be read)
Here is the call graph for this function:

◆ bindNum() [1/8]

BindArg anch::cli::bindNum ( double & dest)

Bind double value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [2/8]

BindArg anch::cli::bindNum ( float & dest)

Bind float value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [3/8]

BindArg anch::cli::bindNum ( int16_t & dest)

Bind int64_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [4/8]

BindArg anch::cli::bindNum ( int32_t & dest)

Bind int32_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [5/8]

BindArg anch::cli::bindNum ( int64_t & dest)

Bind int64_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [6/8]

BindArg anch::cli::bindNum ( uint16_t & dest)

Bind uint16_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [7/8]

BindArg anch::cli::bindNum ( uint32_t & dest)

Bind uint16_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindNum() [8/8]

BindArg anch::cli::bindNum ( uint64_t & dest)

Bind uint32_t value utility function

Parameters
destthe destination
Returns
the binding function (which raises std::invalid_argument when value is empty, is not a number or is out of range ; dest is not modified in this case)
Here is the call graph for this function:

◆ bindOFS() [1/2]

BindArg anch::cli::bindOFS ( std::shared_ptr< std::ofstream > & dest,
std::ios_base::openmode mode = std::ios_base::out )

Bind output file stream

Parameters
destthe std::ofstream to fill
modethe file open mode (default to std::ios_base::out )
Returns
the binding function (which raises std::invalid_argument when file can not be opened for writing)
Here is the call graph for this function:

◆ bindOFS() [2/2]

BindArg anch::cli::bindOFS ( std::shared_ptr< std::ostream > & dest)

Bind output file stream

Parameters
destthe std::ostream to fill
Returns
the binding function (which raises std::invalid_argument when file can not be opened for writing)
Here is the call graph for this function:

◆ bindPath()

BindArg anch::cli::bindPath ( std::filesystem::path & dest)

Bind input file stream

Parameters
destthe std::filesystem::path to fill
Returns
the binding function
Here is the call graph for this function:

◆ bindPipe()

std::function< void(std::istream &)> anch::cli::bindPipe ( std::shared_ptr< std::istream > & dest)

Bind std::cin to input stream

Parameters
destthe destination input stream
Here is the call graph for this function:

◆ bindStr() [1/2]

BindArg anch::cli::bindStr ( std::optional< std::string > & dest)

Bind caracters' string value utility function and macro

Parameters
destthe destination
Returns
the binding function
Here is the call graph for this function:

◆ bindStr() [2/2]

BindArg anch::cli::bindStr ( std::string & dest)

Bind caracters' string value utility function

Parameters
destthe destination
Returns
the binding function
Here is the call graph for this function:

◆ bindTrue()

BindArg anch::cli::bindTrue ( bool & dest)

Bind true utility function

Parameters
destthe bool to set
Returns
the binding function
Here is the call graph for this function:

◆ manageEnvNoFormat()

void anch::cli::manageEnvNoFormat ( )

Disable console formatting when environment variable ANCH_CLI_NO_FMT is set to 1

Here is the call graph for this function:

◆ operator<<()

std::ostream & anch::cli::operator<< ( std::ostream & stream,
const anch::cli::Formatter & fmt )

Formatter output stream operator.
It is declared in anch::cli namespace so that it is found by argument-dependent lookup from any namespace.

Parameters
streamthe output stream to use
fmtthe formatter to use
Returns
the output stream
Here is the call graph for this function:

Variable Documentation

◆ BLINK

anch::cli::Formatter anch::cli::BLINK
extern

Predefined blink formatter

◆ BOLD

anch::cli::Formatter anch::cli::BOLD
extern

Predefined bold formatter

◆ RESET

anch::cli::Formatter anch::cli::RESET
extern

Predefined reset formatter

◆ UNBLINK

anch::cli::Formatter anch::cli::UNBLINK
extern

Predefined unblink formatter

◆ UNBOLD

anch::cli::Formatter anch::cli::UNBOLD
extern

Predefined unbold formatter

◆ UNDERLINE

anch::cli::Formatter anch::cli::UNDERLINE
extern

Predefined underline formatter

◆ UNUNDERLINE

anch::cli::Formatter anch::cli::UNUNDERLINE
extern

Predefined ununderline formatter