Geogram  Version 1.8.9-rc
A programming library of geometric algorithms
GEO::CmdLine Namespace Reference

Utilities to process command line arguments. More...

Typedefs

typedef char ** charptrptr
 

Enumerations

enum  ArgType {
  ARG_UNDEFINED = 0 , ARG_INT = 1 , ARG_DOUBLE = 2 , ARG_STRING = 4 ,
  ARG_BOOL = 8 , ARG_PERCENT = 16
}
 Command line argument types. More...
 
enum  ArgFlags { ARG_FLAGS_DEFAULT = 0 , ARG_ADVANCED = 1 }
 Command line group or argument flags. More...
 

Functions

void initialize ()
 Initializes the command line framework. More...
 
void terminate ()
 Cleans up the command line framework. More...
 
void set_config_file_name (const std::string &filename, bool auto_create_args=false)
 Defines the name of the configuration file. More...
 
bool config_file_loaded ()
 Tests whether the configuration file was loaded. More...
 
std::string get_config_file_name ()
 Gets the name of the configuration file. More...
 
void load_config (const std::string &filename, const std::string &program_name)
 Loads command line argument values from a file. More...
 
void declare_arg_group (const std::string &name, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument group. More...
 
void declare_arg (const std::string &name, ArgType type, const std::string &default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument. More...
 
ArgType get_arg_type (const std::string &name)
 Gets the type of an argument. More...
 
bool arg_is_declared (const std::string &name)
 Checks if an argument exists. More...
 
void declare_arg (const std::string &name, const std::string &default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type string. More...
 
void declare_arg (const std::string &name, const char *default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type string. More...
 
void declare_arg (const std::string &name, int default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type integer. More...
 
void declare_arg (const std::string &name, double default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type floating point. More...
 
void declare_arg (const std::string &name, bool default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type boolean. More...
 
void declare_arg_percent (const std::string &name, double default_value, const std::string &description="...", ArgFlags flags=ARG_FLAGS_DEFAULT)
 Declares an argument of type percentage. More...
 
bool parse (int argc, char **argv, std::vector< std::string > &unparsed_args, const std::string &additional_arg_specs="")
 Parses the command line arguments. More...
 
bool parse (int argc, char **argv)
 Parses the command line arguments. More...
 
int argc ()
 Gets the number of arguments of the command line. More...
 
charptrptr argv ()
 Gets the command line arguments. More...
 
void show_usage (const std::string &additional_args="", bool advanced=false)
 Displays program help. More...
 
std::string get_arg (const std::string &name)
 Gets an argument value. More...
 
int get_arg_int (const std::string &name)
 Gets an argument value as an integer. More...
 
unsigned int get_arg_uint (const std::string &name)
 Gets an argument value as an unsigned integer. More...
 
double get_arg_double (const std::string &name)
 Gets an argument value as a floating point. More...
 
double get_arg_percent (const std::string &name, double reference)
 Gets an argument value as a percentage. More...
 
bool get_arg_bool (const std::string &name)
 Gets an argument value as a boolean. More...
 
bool set_arg (const std::string &name, const std::string &value)
 Sets an argument value from a string. More...
 
bool set_arg (const std::string &name, const char *value)
 Sets an argument value from a C-string. More...
 
void set_arg (const std::string &name, Numeric::int32 value)
 Sets an argument value from an integer. More...
 
void set_arg (const std::string &name, Numeric::uint32 value)
 
void set_arg (const std::string &name, Numeric::int64 value)
 
void set_arg (const std::string &name, Numeric::uint64 value)
 
void set_arg (const std::string &name, double value)
 Sets an argument value from a floating point. More...
 
void set_arg (const std::string &name, bool value)
 Sets an argument value from a boolean. More...
 
void set_arg_percent (const std::string &name, double value)
 Sets an argument value from a percentage. More...
 
void get_args (std::vector< std::string > &args)
 Gets the value of all arguments. More...
 
index_t ui_terminal_width ()
 Gets the width of the console. More...
 
void ui_separator (const std::string &title, const std::string &short_title="")
 Outputs a separator with a title on the console. More...
 
void ui_separator ()
 Outputs a separator without a title on the console. More...
 
void ui_close_separator ()
 Closes an opened separator. More...
 
void ui_message (const std::string &message, index_t wrap_margin)
 Outputs a message on the console. More...
 
void ui_message (const std::string &message)
 Outputs a message on the console. More...
 
void ui_clear_line ()
 Clears the last line. More...
 
void ui_progress (const std::string &task_name, index_t val, index_t percent, bool clear=true)
 Displays a progress bar. More...
 
void ui_progress_time (const std::string &task_name, double elapsed, bool clear=true)
 Displays the time elapsed for a completed task. More...
 
void ui_progress_canceled (const std::string &task_name, double elapsed, index_t percent, bool clear=true)
 Displays the time elapsed for a canceled task. More...
 
std::string ui_feature (const std::string &feature, bool show=true)
 Formats a Logger feature name. More...
 
bool import_arg_group (const std::string &name)
 Imports a group of command line arguments. More...
 
bool set_profile (const std::string &name)
 Sets the current application profile. More...
 

Detailed Description

Utilities to process command line arguments.

CmdLine defines utility functions to declare program options and parse command line arguments.

Enumeration Type Documentation

◆ ArgFlags

Command line group or argument flags.

Enumerator
ARG_FLAGS_DEFAULT 

Default argument flags (nothing)

ARG_ADVANCED 

Argument is advanced

Definition at line 146 of file command_line.h.

◆ ArgType

Command line argument types.

Enumerator
ARG_UNDEFINED 

Argument type is undefined

ARG_INT 

Argument is a signed integer

ARG_DOUBLE 

Argument is a floating point value

ARG_STRING 

Argument is a string

ARG_BOOL 

Argument is a boolean

ARG_PERCENT 

Argument is a percentage

Definition at line 128 of file command_line.h.

Function Documentation

◆ arg_is_declared()

bool GEO::CmdLine::arg_is_declared ( const std::string &  name)

Checks if an argument exists.

Parameters
[in]namethe argument name
Return values
trueif the argument exists
falseotherwise

◆ argc()

int GEO::CmdLine::argc ( )

Gets the number of arguments of the command line.

Returns
the number of arguments plus one.

parse() should be called before.

◆ argv()

charptrptr GEO::CmdLine::argv ( )

Gets the command line arguments.

Returns
a pointer to an array of null-terminated strings with the command line arguments. The first one is the program name.

parse() should be called before.

◆ config_file_loaded()

bool GEO::CmdLine::config_file_loaded ( )

Tests whether the configuration file was loaded.

The default configuration file, or the one specified by set_config_file_name() may not exist, in this case this function returns false.

Return values
trueif the configuration file was loaded.
falseotherwise.

◆ declare_arg() [1/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
ArgType  type,
const std::string &  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)

Declares an argument.

This is the general function for declaring an argument of name name. The default value default_value is given as a string and must be convertible to the given type type. The command line framework provides type-safe variants of declare_arg() for declaring arguments, it is highly recommended to use them.

Argument names can have 2 forms:

  • "group:arg" - the argument "arg" is added to the group "group".
  • "arg" - without a group name, the argument "arg" is added to the default group "global"
Parameters
[in]namethe argument name
[in]typethe argument type
[in]default_valuethe default value as a string
[in]descriptionthe argument description
[in]flagsthe argument flags

◆ declare_arg() [2/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
bool  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type boolean.

Parameters
[in]namethe argument name
[in]default_valueargument's default boolean value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 305 of file command_line.h.

◆ declare_arg() [3/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
const char *  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type string.

Parameters
[in]namethe argument name
[in]default_valueargument's default C-string value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 248 of file command_line.h.

◆ declare_arg() [4/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
const std::string &  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type string.

Parameters
[in]namethe argument name
[in]default_valueargument's default string value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 229 of file command_line.h.

◆ declare_arg() [5/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
double  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type floating point.

Parameters
[in]namethe argument name
[in]default_valueargument's default floating point value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 286 of file command_line.h.

◆ declare_arg() [6/6]

void GEO::CmdLine::declare_arg ( const std::string &  name,
int  default_value,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type integer.

Parameters
[in]namethe argument name
[in]default_valueargument's default integer value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 267 of file command_line.h.

◆ declare_arg_group()

void GEO::CmdLine::declare_arg_group ( const std::string &  name,
const std::string &  description,
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)

Declares an argument group.

This creates a new argument group with the given name name. If a group with the same name already exists, the new group is not created.

Argument groups are used to organize arguments in a set of logically related arguments. For instance:

  • group "sys" contains arguments to configure the Process module,
  • group "log" contains arguments to configure the Logger,
  • ...

    To declare an argument in a given group, the argument name must be prefixed by the group name followed by a colon as in "group:arg".

Parameters
[in]namethe group name
[in]descriptionthe group description
[in]flagsthe group flags
See also
declare_arg()

◆ declare_arg_percent()

void GEO::CmdLine::declare_arg_percent ( const std::string &  name,
double  default_value,
const std::string &  description = "...",
ArgFlags  flags = ARG_FLAGS_DEFAULT 
)
inline

Declares an argument of type percentage.

Percentage values are normal floating point values, except that their string representation is followed by a percent "%" sign.

Parameters
[in]namethe argument name
[in]default_valueargument's default percentage value
[in]descriptionargument description
[in]flagsthe argument flags

Definition at line 326 of file command_line.h.

◆ get_arg()

std::string GEO::CmdLine::get_arg ( const std::string &  name)

Gets an argument value.

Retrieves the string value of argument name. If the argument does not exist, then the function calls abort().

Parameters
[in]namethe argument name
Returns
the value of the argument as a string if it exists

◆ get_arg_bool()

bool GEO::CmdLine::get_arg_bool ( const std::string &  name)

Gets an argument value as a boolean.

Retrieves the value of argument name and converts it to an integer. If the argument does not exists or its value is not convertible to a boolean, then the function aborts.

Parameters
[in]namethe argument name
Returns
the argument value converted to a boolean if the argument exists
See also
String::to_bool()

◆ get_arg_double()

double GEO::CmdLine::get_arg_double ( const std::string &  name)

Gets an argument value as a floating point.

Retrieves the value of argument name and converts it to a floating point. If the argument does not exists or its value is not convertible to a floating point, then the function aborts.

Parameters
[in]namethe argument name
Returns
the argument value converted to a floating point if the argument exists
See also
String::to_double()

◆ get_arg_int()

int GEO::CmdLine::get_arg_int ( const std::string &  name)

Gets an argument value as an integer.

Retrieves the value of argument name and converts it to an integer. If the argument does not exists or its value is not convertible to an integer, then the function aborts.

Parameters
[in]namethe argument name
Returns
the argument value converted to an integer if the argument exists
See also
String::to_int()

◆ get_arg_percent()

double GEO::CmdLine::get_arg_percent ( const std::string &  name,
double  reference 
)

Gets an argument value as a percentage.

Retrieves the value of argument name:

  • if the value has the form of a percentage "dd%", it is considered as a relative error of the parameter reference. The returned value is the floating point value 0.01*dd multiplied by the parameter reference.
  • if the value is directly convertible to a floating point number, it is considered as an "absolute error" and returned as is. In this case parameter reference is ignored.
  • in all other cases, the function aborts
    Parameters
    [in]namethe argument name
    [in]referencethe value to apply the percentage to
    Returns
    either:
  • the argument value converted to a percentage of the reference
  • or the floating point value of argument name
    See also
    String::to_double()

◆ get_arg_type()

ArgType GEO::CmdLine::get_arg_type ( const std::string &  name)

Gets the type of an argument.

Parameters
[in]namethe argument name
Return values
thetype of the argument if it exists
ARG_UNDEFINEDotherwise

◆ get_arg_uint()

unsigned int GEO::CmdLine::get_arg_uint ( const std::string &  name)

Gets an argument value as an unsigned integer.

Retrieves the value of argument name and converts it to an unsigned integer. If the argument does not exists or its value is not convertible to an unsigned integer, then the function aborts.

Parameters
[in]namethe argument name
Returns
the argument value converted to an unsigned integer if the argument exists
See also
String::to_uint()

◆ get_args()

void GEO::CmdLine::get_args ( std::vector< std::string > &  args)

Gets the value of all arguments.

Stores in vector args the value of all declared arguments in the form "name=value".

Parameters
[out]argsoutput vector

◆ get_config_file_name()

std::string GEO::CmdLine::get_config_file_name ( )

Gets the name of the configuration file.

Returns
the name of the configuration file, as specified by set_config_file_name(). User's home directory needs to be prepended to have the complete file path.

◆ import_arg_group()

bool GEO::CmdLine::import_arg_group ( const std::string &  name)

Imports a group of command line arguments.

The behavior of the the Vorpaline library is controlled by several properties organized in the following groups:

  • global - global options (profile, debug).
  • sys - Process settings (FPE, multithreading, ...).
  • log - Logger settings.
  • standard - standard settings (global + sys + log).
  • pre - configuration of the pre-processing phase.
  • remesh - configuration of the remeshing phase.
  • post - configuration of the post-processing phase.
  • algo - fine-tuning of the algorithms.
  • opt - fine-tuning of the optimizer.
  • co3ne - configuration of the reconstruction phase.
  • stat - Statistics settings

To allow setting the properties from the command line, users must declare command line arguments and groups for the Vorpaline properties that they want to control, plus their own specific command line options. The function import_arg_group() relieves users of this tiresome and repetitive task by declaring a whole group of command line arguments.

The following example illustrates how to use import_arg_group() in a main program, to declare command line options for the "standard" and "remesh" Vorpaline property groups:

int main(int argc, char* argv[]) {
import_arg_group("standard");
import_arg_group("remesh");
declare_arg("useroption1", "default value", "This controls...");
declare_arg("useroption2", "default value", "This controls...");
...
return 0;
}
void declare_arg(const std::string &name, ArgType type, const std::string &default_value, const std::string &description, ArgFlags flags=ARG_FLAGS_DEFAULT)
Declares an argument.
int argc()
Gets the number of arguments of the command line.
charptrptr argv()
Gets the command line arguments.
bool import_arg_group(const std::string &name)
Imports a group of command line arguments.
void initialize(int flags=GEOGRAM_INSTALL_HANDLERS)
Initialize Geogram.
Parameters
[in]namethe name of the group to import.
Return values

◆ initialize()

void GEO::CmdLine::initialize ( )

Initializes the command line framework.

This function must be called once at program start. It is called by the general initialization function GEO::initialize().

See also
GEO::initialize().

◆ load_config()

void GEO::CmdLine::load_config ( const std::string &  filename,
const std::string &  program_name 
)

Loads command line argument values from a file.

only args in the section with program_name are loaded.

Parameters
[in]filenamethe complete path to the file.
[in]program_namethe name of the program.

◆ parse() [1/2]

bool GEO::CmdLine::parse ( int  argc,
char **  argv 
)

Parses the command line arguments.

This is a simplified version of parse() which does not accept additional unparsed arguments.

Parameters
[in]argcnumber of arguments passed to main()
[in]argvarray of command line arguments passed to main()
Return values
trueif the command line arguments are successfully parsed
falseotherwise

◆ parse() [2/2]

bool GEO::CmdLine::parse ( int  argc,
char **  argv,
std::vector< std::string > &  unparsed_args,
const std::string &  additional_arg_specs = "" 
)

Parses the command line arguments.

This analyzes command line arguments passed to the main() program in argc and argv. Arguments not matching program options declared with declare_arg() are stored in output vector unparsed_args.

Command line parsing allows users to specify partial option names on the command line. If a partial name matches more than 1 declared argument, it is rejected and the functions fails, otherwise, it is accepted and replaced by the full argument name.

Parameter additional_arg_specs specifies how to handle unparsed arguments. It consists in a white space separated list of additional argument names expected by the program, with the following meaning:

  • "<arg_name>" - means that the argument is optional
  • "arg_name" - means that the argument is mandatory

For instance the following additional argument specification:

"input_file <option_file> <output_file>

means that the program expects at least one additional argument input_file, with two additional optional arguments option_file and output_file.

If argument "-h" is found in the list of arguments, then the program displays a summary of program options and exits (see show_usage()).

Parameters
[in]argcnumber of arguments passed to main()
[in]argvarray of command line arguments passed to main()
[out]unparsed_argsoutput vector of unparsed arguments
[in]additional_arg_specsunparsed argument specification
Return values
trueif the command line arguments are successfully parsed
falseotherwise

◆ set_arg() [1/5]

void GEO::CmdLine::set_arg ( const std::string &  name,
bool  value 
)

Sets an argument value from a boolean.

This replaces the value of argument name by the given boolean value. If the declared type of the argument is not compatible with a boolean then the function aborts (compatible argument types are: boolean or string). If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as a floating point

◆ set_arg() [2/5]

bool GEO::CmdLine::set_arg ( const std::string &  name,
const char *  value 
)
inline

Sets an argument value from a C-string.

This replaces the value of argument name by the given C-string value. If the string value is not strictly convertible to the declared type of the argument then the function aborts. If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as a C-string
Return values
trueif the argument was successfully set
falseotherwise

Definition at line 538 of file command_line.h.

◆ set_arg() [3/5]

bool GEO::CmdLine::set_arg ( const std::string &  name,
const std::string &  value 
)

Sets an argument value from a string.

This replaces the value of argument name by the given string value. If the string value is not strictly convertible to the declared type of the argument then the function aborts. If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as a string
Return values
trueif the argument was successfully set
falseotherwise

◆ set_arg() [4/5]

void GEO::CmdLine::set_arg ( const std::string &  name,
double  value 
)

Sets an argument value from a floating point.

This replaces the value of argument name by the given floating point value. If the declared type of the argument is not compatible with a floating point then the function aborts (compatible argument types are: double or string). If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as a floating point

◆ set_arg() [5/5]

void GEO::CmdLine::set_arg ( const std::string &  name,
Numeric::int32  value 
)

Sets an argument value from an integer.

This replaces the value of argument name by the given integer value. If the declared type of the argument is not compatible with an integer then the function aborts (compatible argument types are: int, double or string). If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as an integer

◆ set_arg_percent()

void GEO::CmdLine::set_arg_percent ( const std::string &  name,
double  value 
)

Sets an argument value from a percentage.

This replaces the value of argument name by the given floating point value. If the declared type of the argument is not compatible with a floating point then the function aborts (compatible argument types are: double or string), otherwise the argument receives the value converted to a floating with a trailing '' sign. If the argument does not exist, it is added as a new argument of undefined type.

Parameters
[in]namethe argument name
[in]valuethe new value as a floating point

◆ set_config_file_name()

void GEO::CmdLine::set_config_file_name ( const std::string &  filename,
bool  auto_create_args = false 
)

Defines the name of the configuration file.

Parameters
[in]filenamethe name of the configuration file. Before parsing command line arguments, arguments are set according to this file, loaded from the home directory (or 'My Documents' under Windows). Default is 'geogram.ini'.
[in]auto_create_argsif set, all the args present in the configuration file are created if they do not already exist, else a warning message is displayed for args that do not exist.

◆ set_profile()

bool GEO::CmdLine::set_profile ( const std::string &  name)

Sets the current application profile.

A profile is a predefined set of property values that affect the configuration of the Vorpaline library in order to perform very specific tasks. Only a single profile can be active at a time, but nothing prevents from tweaking indivual properties to fine tune the profile values.

Vorpaline defines the following profiles:

  • cad - configures Vorpaline to process files issued from CAD software.
  • scan - configures Vorpaline to process files issued from 3D scanners.
  • convert - performs file conversion only. No remeshing.
  • repair - repares small problems in input data, no remeshing.
  • heal - repares bigger problems in the input data, using remeshing.
  • reconstruct - reconstructs a mesh from scratch using the points of the the input data (input triangles are ignored).
Parameters
[in]namethe name of the profile, as defined above.
Return values

◆ show_usage()

void GEO::CmdLine::show_usage ( const std::string &  additional_args = "",
bool  advanced = false 
)

Displays program help.

Displays a list of all declared arguments (sorted by argument group) with their current value. By default, show_usage() only displays standard groups and arguments. If parameter advanced is set to true, show_usage() also displays advanced groups and arguments (declared with flag ARG_ADVANCED).

Parameters
[in]additional_argsadditional argument specification (see parse()).
[in]advancedboolean flag that controls the display of advanced groups and arguments.

◆ terminate()

void GEO::CmdLine::terminate ( )

Cleans up the command line framework.

This function must be called at program termination program. It is called by the general cleanup function GEO::terminate().

See also
GEO::terminate().

◆ ui_clear_line()

void GEO::CmdLine::ui_clear_line ( )

Clears the last line.

This function is only used in pretty mode and mainly to display progress bars.

◆ ui_close_separator()

void GEO::CmdLine::ui_close_separator ( )

Closes an opened separator.

This closes the last opened box. When the Logger is in pretty mode, the separator has the following form:

\\________________________________________/

In non-pretty mode, or if the program output is redirected to a file, nothing is printed.

◆ ui_feature()

std::string GEO::CmdLine::ui_feature ( const std::string &  feature,
bool  show = true 
)

Formats a Logger feature name.

Logger features are displayed with a special formatting in the output log. They precede the messages sent to the Logger as illustrated below:

o-[feature ] message...

Multiple messages sent to the Logger with the same feature display the feature only once:

o-[feature ] first message ...
second message with the same feature...

If parameter show is set to true, the function returns the feature formatted as for the first message in the example above. If show is set to false, the functions returns an empty placeholder used as a left margin length.

Parameters
[in]featurethe text of the feature
[in]showtrue to actually display the feature name or false to return an empty placeholder of the same width
Returns
the formatted feature

◆ ui_message() [1/2]

void GEO::CmdLine::ui_message ( const std::string &  message)

Outputs a message on the console.

This is a variant of ui_message() with a default wrap_margin that keeps wrapped lines aligned with the end of the feature names.

Parameters
[in]messagethe message to print
See also
ui_feature()

◆ ui_message() [2/2]

void GEO::CmdLine::ui_message ( const std::string &  message,
index_t  wrap_margin 
)

Outputs a message on the console.

Prints the message message to the console. In pretty mode, the message is enclosed in vertical bars, thus forming a box with the previous separator (see ui_separator()). If the message is too long to fit in the console width, it is wrapped on the next line(s) with an additional left margin given by wrap_margin.

| This is an example of a very very long |
| <wrap_margin> message that wraps on th |
| <wrap_margin> e next lines |

In non-pretty mode, the message is printed "as is".

Parameters
[in]messagethe message to print
[in]wrap_marginextra left margin used to print continuation lines of long messages

◆ ui_progress()

void GEO::CmdLine::ui_progress ( const std::string &  task_name,
index_t  val,
index_t  percent,
bool  clear = true 
)

Displays a progress bar.

This displays a progress bar for the given task task name. The progress of the task is specified by the current progress value val and the percentage of completion percent. The progress bar is formatted as illustrated below:

o-[task_name ] (wheel)-[val]-[percent]--[waves]

where:

  • wheel is an animated rotating progress wheel
  • waves is an animated progress bar Once the task has completed, one should call ui_progress_time() to display the elapsed time of for the task.
    Parameters
    [in]task_namethe name of the task in progress
    [in]valthe current progress value
    [in]percentthe percentage of completion
    [in]clearwhether to clear the line before displaying the progress bar (default is true)
    See also
    ui_progress_time()

◆ ui_progress_canceled()

void GEO::CmdLine::ui_progress_canceled ( const std::string &  task_name,
double  elapsed,
index_t  percent,
bool  clear = true 
)

Displays the time elapsed for a canceled task.

Call this function when a task has been canceled to display the elapsed time elapsed and the percentage of completion percent.

Parameters
[in]task_namethe name of the task being completed.
[in]elapsedthe time elapsed since the beginning of the task
[in]percentthe percentage of completion of the task
[in]clearwhether to clear the line before displaying the progress bar (default is true)
See also
ui_progress()

◆ ui_progress_time()

void GEO::CmdLine::ui_progress_time ( const std::string &  task_name,
double  elapsed,
bool  clear = true 
)

Displays the time elapsed for a completed task.

Call this function after successive calls to ui_progress() to display the elapsed time once the task task task_name has completed.

Parameters
[in]task_namethe name of the task being completed.
[in]elapsedthe time elapsed for completing the task
[in]clearwhether to clear the line before displaying the progress bar (default is true)
See also
ui_progress()

◆ ui_separator() [1/2]

void GEO::CmdLine::ui_separator ( )

Outputs a separator without a title on the console.

Prints a simple separator string on the console. When the Logger is in pretty mode, the separator has the following form:

________________________________________
| |

In non-pretty mode, or if the program output is redirected to a file, nothing is printed.

◆ ui_separator() [2/2]

void GEO::CmdLine::ui_separator ( const std::string &  title,
const std::string &  short_title = "" 
)

Outputs a separator with a title on the console.

Prints a separator string on the console that contains the given title and optional short_title. If it is specified, the short_title appears on the left of title in the separator as illustrated below. This function is used by Logger::div() to create a new division in the log output.

When the Logger is in pretty mode, the separator has the following form:

_/ ==[short_title]====[title]== \\______
| |

Otherwise the separator has the following form In non-pretty mode, or if the program output is redirected to a file, the separator has the following form:

==[short_title]====[title]==
Parameters
[in]titlethe main title string
[in]short_titleoptional title that appears on the left of title
See also
Logger::div()

◆ ui_terminal_width()

index_t GEO::CmdLine::ui_terminal_width ( )

Gets the width of the console.

Returns
the console width in number of characters