advgetopt 2.0.49
Parse complex command line arguments and configuration files in C++.
Functions | Variables
advgetopt::anonymous_namespace{advgetopt.cpp} Namespace Reference

Functions

void check_for_show_sources (int argc, char *argv[])
 Check for a "--show-option-sources" flag.
 
bool is_arg (char const *a)
 Check whether this parameter is an argument.
 

Variables

option const g_if_configuration_filename_system_options []
 Optional list of options.
 
option const g_system_options []
 Definitions of the system options.
 

Function Documentation

◆ check_for_show_sources()

void advgetopt::anonymous_namespace{advgetopt.cpp}::check_for_show_sources ( int  argc,
char argv[] 
)

When this flag is defined, we turn on the trace mode in the option_info class (which is a global flag). That way we can honor the "--show-option-sources" when we are done parsing the configuration files, environment variable, and command line.

Parameters
[in]argcThe number of items in the argv array.
[in]argvThe arguments.

Definition at line 347 of file advgetopt.cpp.

References check_for_show_sources(), and advgetopt::option_info::set_trace_sources().

Referenced by check_for_show_sources().

◆ is_arg()

An argument is defined as a command line parameter that starts with a dash and is not just "-".

Note that "--" is viewed as an argument (this function returns true) and the getopt class takes it as a command meaning any other parameter is not an argument.

Definition at line 328 of file advgetopt.cpp.

References is_arg().

Referenced by is_arg().

Variable Documentation

◆ g_if_configuration_filename_system_options

option const advgetopt::anonymous_namespace{advgetopt.cpp}::g_if_configuration_filename_system_options[]
Initial value:
=
{
Name("config-dir")
, Flags(any_flags<GETOPT_FLAG_COMMAND_LINE
, GETOPT_FLAG_ENVIRONMENT_VARIABLE
, GETOPT_FLAG_REQUIRED
, GETOPT_FLAG_MULTIPLE
, GETOPT_FLAG_GROUP_OPTIONS>())
, Help("add one or more configuration directory paths to search for configuration files.")
),
}
constexpr option define_option(ARGS ...args)
Definition options.h:259
constexpr option end_options()
Definition options.h:294

This optional list of options is added only when the f_configuration_filename parameter has a valid filename.

The following are the currently added options:

  • --config-dir

This option allows for adding more configuration directories. These work the same way as directories defined in the f_configuration_directories.

Definition at line 302 of file advgetopt.cpp.

◆ g_system_options

The system options are options we add automatically (if the user asked for them) and handle automatically when they are found.

The following are the currently supported system options:

  • --help

Print out the usage() with most of the command line arguments.

  • '–long-help'

Print all the command line arguments with usage().

The long help is is only added if the list of options include at least one group flag (GETOPT_FLAG_SHOW_GROUP1 or GETOPT_FLAG_SHOW_GROUP2). See the getopt::parse_options_from_group_names() in advgetopt_usage.cpp.

  • '–<name>-help'

Print the help from the group named <name>.

These command line options are added only when groups are defined.

  • --version

Print out the version.

  • --copyright

Print out the copyright notice.

  • --license

Print out the license notice.

  • --build-date

Print out the build time and date.

  • --environment-variable-name

Print out the build time and date.

  • --configuration-filenames

Print out the list of configuration file names that the system checks for configuration data.

  • --path-to-option-definitions

Print out the path to files which define options for this tool.

  • --source-option-sources

Print out all the options and their sources. This shows you where a value come from: command line, environment variable, configuration file, etc.

Todo:
Add a --config option to allow the user to name one specific configuration file to use with an executable.

Definition at line 197 of file advgetopt.cpp.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.