(
void);
48 virtual int Run(
void);
49 virtual void Exit(
void);
67arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
68 "CArgDescriptions demo program");
71arg_desc->AddOptionalPositional
73 "This is an optional named positional argument without default value",
79 "This is a flag argument: TRUE if set, FALSE if not set");
81arg_desc->AddPositional
83 "This is a mandatory plain (named positional) argument",
85arg_desc->SetConstraint
90arg_desc->AddDefaultKey
91(
"kd",
"DefaultKey",
92 "This is an optional integer key argument, with default value",
94arg_desc->SetConstraint
100 "These are the optional extra (unnamed positional) arguments. " 101 "They will be printed out to the file specified by the " 102 "2nd positional argument,\n\"logfile\"",
106(
"k",
"MandatoryKey",
107 "This is a mandatory alpha-num key argument",
109arg_desc->SetConstraint
112arg_desc->AddOptionalKey
113(
"ko",
"OptionalKey",
114 "This is another optional key argument, without default value",
120 "This is another flag argument: FALSE if set, TRUE if not set",
123arg_desc->AddDefaultPositional
125 "This is an optional named positional argument with default value",
127arg_desc->SetConstraint
144cout <<
string(72,
'=') << endl;
153ostream* x_lg = args[
"logfile"] ? &args[
"logfile"].AsOutputFile() : &cout;
156 if( args[
"logfile"] )
157cout <<
"Printing arguments to file `" 158<< args[
"logfile"].AsString() <<
"'..."<< endl;
161 lg<<
"k: "<< args[
"k"].AsString() << endl;
162 lg<<
"barfooetc: "<< args[
"barfooetc"].AsString() << endl;
163 if( args[
"logfile"] )
164 lg<<
"logfile: "<< args[
"logfile"].AsString() << endl;
166 if( args[
"ko"] ) {
170 if(!ko_values.empty()) {
172 for(
const auto& v: ko_values) {
179 lg<<
"ko: not provided"<< endl;
182(void) args[
"ko"].AsString();
185message = e.
what();
190 if( args[
"f1"] ) {
191 _ASSERT(args[
"f1"].AsBoolean());
193 if( args[
"f2"] ) {
194 _ASSERT(args[
"f2"].AsBoolean());
199 for(
size_textra = 1; extra <= args.
GetNExtra(); extra++) {
200 lg<<
"#"<< extra <<
": " 202<<
" (passed as `"<< args[extra].AsString() <<
"')" 206 lg<<
"(no unnamed positional arguments passed in the cmd-line)"<< endl;
214cout << args.
Print(
str) << endl;
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
virtual int Run(void)
Run the application.
virtual void Init(void)
Initialize the application.
virtual void Exit(void)
Cleanup on application exit.
static const char * str(char *buf, int n)
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
string & Print(string &str) const
Print (append) all arguments to the string "str" and return "str".
bool Exist(const string &name) const
Check existence of argument description.
vector< string > TStringArray
Some values types can contain several value lists.
size_t GetNExtra(void) const
Get the number of unnamed positional (a.k.a. extra) args.
@ fAllowMultiple
Repeated key arguments are legal (use with AddKey)
@ fBinary
Open as binary file; for eInputFile, eOutputFile, eIOFile.
@ fPreOpen
Open file right away; for eInputFile, eOutputFile, eIOFile.
@ eBoolean
{'true', 't', 'false', 'f'}, case-insensitive
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
@ eInteger
Convertible into an integer number (int or Int8)
@ eAlnum
Alphanumeric characters.
@ eConstraint
Constraint is not inverted (taken as is)
#define NCBI_REPORT_EXCEPTION(title, ex)
Generate a report on the exception.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
static const string BoolToString(bool value)
Convert bool to string.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application:
static SLJIT_INLINE sljit_ins lg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4