|
libfossil
|
The fcli_t type, accessed by clients via the fcli global instance, contains various data for managing a basic Fossil SCM application build using libfossil. More...
#include "cli.h"
Data Fields | |
| char const * | appName |
| Application's name. | |
| int | argc |
| Current number of items in this->argv. | |
| char ** | argv |
| The current list of CLI arguments. | |
| struct { | |
| fcli_help_info const * appHelp | |
| If not NULL, it must be a pointer to fcli_help_info holding help info for the app. More... | |
| char const * checkoutDir | |
| If not NULL then fcli_setup() will attempt to open the checkout for the given dir, including its associated repo db. More... | |
| const fcli_cliflag * cliFlags | |
| May be set to an array of CLI flag objects, which fcli_setup() will use for parsing the CLI flags. More... | |
| fsl_msg_listener listener | |
| Listener for fsl_msg-published messages. More... | |
| fsl_outputer outputer | |
| This output channel is used when initializing the context object. More... | |
| int traceSql | |
| Whether or not to enable fossil's SQL tracing. More... | |
| unsigned short verbose | |
| A verbosity level counter. More... | |
| } | config |
| The flags in this struct are "public," meaning that client applications may query and safely manipulate them directly if they know what they're doing. | |
| fsl_error | err |
| For holding pre-this->f-init error state. | |
| fsl_cx * | f |
| The shared fsl_cx instance. | |
| struct { | |
| fsl_pathfinder bins | |
| Search object for binaries. More... | |
| } | paths |
| Search paths. | |
| struct { | |
| const char * key | |
| Key passed to the –see-key CLI flag. More... | |
| unsigned int nKey | |
| Key len. More... | |
| enum fsl_see_keytype_e type | |
| Key type. More... | |
| } | see |
| struct { | |
| short helpRequested | |
| Incremented if fcli_setup() detects -? More... | |
| const char * repoDbArg | |
| repo db name string from -R/–repo CLI flag. More... | |
| const char * userArg | |
| User name from the –user CLI flag. More... | |
| bool versionRequested | |
| True if the –lib-version CLI flag was used. More... | |
| } | transient |
| Transient settings and flags. | |
The fcli_t type, accessed by clients via the fcli global instance, contains various data for managing a basic Fossil SCM application build using libfossil.
Usage notes:
| fcli_help_info const* fcli_t::appHelp |
If not NULL, it must be a pointer to fcli_help_info holding help info for the app.
It will be formated and output when –help is triggered.
Should be set by client applications BEFORE calling fcli_setup() so that the fcli help subsystem can integrate the app. fcli.appName will be set by the time this is used.
| char const* fcli_t::appName |
| char** fcli_t::argv |
The current list of CLI arguments.
This list gets modified by fcli_flag() and friends. Its memory is owned by fcli.
| fsl_pathfinder fcli_t::bins |
| char const* fcli_t::checkoutDir |
If not NULL then fcli_setup() will attempt to open the checkout for the given dir, including its associated repo db.
By default this is "." (the current directory).
Applications can set this to NULL before calling fcli_setup() in order to disable the automatic attemp to open a checkout under the current directory. Doing so is equivalent to using the –no-checkout flag. The global –checkout-dir flag will trump that setting, though.
| const fcli_cliflag* fcli_t::cliFlags |
May be set to an array of CLI flag objects, which fcli_setup() will use for parsing the CLI flags.
The array MUST end with an entry which has NULL values for its (flagShort, flagLong) members. When creating the array it is simplest to use fcli_cliflag_empty_m as the initializer for that sentinel entry.
The elements in this array are traversed in the order they are provided, and any which have a callback which returns FCLI_RC_FLAG_AGAIN will be traversed repeatedly before moving on to the next flag. This ordering may have side-effects on how the app sets up its flag handling. In particular, this arrangement makes the common cases easy to implement but makes certain more complicated situations effectively impossible to implement. For example:
Assuming the definition of the -y flag is first in this array and has a callback which returns FCLI_RC_FLAG_AGAIN, the two -x flags will be processed before either of the -y flags. Thus it is impossible (using this method of traversal) to change the behavior of the -y flags based on the left-closest -x value.
We "could," but probably never will, instead walk the input argv looking for things which look like flags, then looking back into this list for a match, rather than the other way around. That would require a new args processing implementation, though, for relatively little benefit.
| struct { ... } fcli_t::config |
The flags in this struct are "public," meaning that client applications may query and safely manipulate them directly if they know what they're doing.
However, some of this state is only be legally modified before calling fcli_setup() (or equivalent).
| fsl_error fcli_t::err |
For holding pre-this->f-init error state.
Once this->f is initialized, all errors reported via fcli_err_set() are stored in that object's error state.
| fsl_cx* fcli_t::f |
The shared fsl_cx instance.
It gets initialized by fcli_setup() and cleaned up post-main().
this->f is owned by this object and will be cleaned up at app shutdown (post-main).
| short fcli_t::helpRequested |
Incremented if fcli_setup() detects -?
or –help in the argument list, or if the first non-flag argument is "help". This is an int, rather than a bool, to support multiple levels of help verbosity via multiple –help flags.
| fsl_msg_listener fcli_t::listener |
| fsl_outputer fcli_t::outputer |
| struct { ... } fcli_t::paths |
Search paths.
| const char* fcli_t::repoDbArg |
| struct { ... } fcli_t::see |
| int fcli_t::traceSql |
Whether or not to enable fossil's SQL tracing.
This should start with a negative value, which helps fcli_setup() process it. Setting this after initialization has no effect.
| struct { ... } fcli_t::transient |
Transient settings and flags.
These are bits which are used during (or very shortly after) fcli_setup() but have no effect if modified after that.
| enum fsl_see_keytype_e fcli_t::type |
| const char* fcli_t::userArg |
| unsigned short fcli_t::verbose |
| bool fcli_t::versionRequested |