Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
clapp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libclapp
clapp
Commits
5bfa67b3
Commit
5bfa67b3
authored
2 years ago
by
Martin Wölzer
Browse files
Options
Downloads
Patches
Plain Diff
examples/sub_parser_example.cpp: fixed code
parent
1c9a74e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Add support for option-container
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/sub_parser_example.cpp
+17
-8
17 additions, 8 deletions
examples/sub_parser_example.cpp
with
17 additions
and
8 deletions
examples/sub_parser_example.cpp
+
17
−
8
View file @
5bfa67b3
...
...
@@ -27,23 +27,30 @@ class cli_parser_t : public clapp::basic_main_parser_t {
~
cli_parser_t
()
override
;
// if help is given, help is printed and exit(EXIT_SUCCESS) is called
clapp
::
help_option_t
help
{
*
this
,
"help"
,
'h'
,
"Show help options."
};
clapp
::
help_option_t
help
{
*
this
,
"help"
,
'h'
,
"Show help options."
,
purpose_t
::
optional
};
// if version is given, print_version_and_exit() is called.
clapp
::
bool_option_t
version
{
*
this
,
"version"
,
"Show version info"
,
clapp
::
value
::
found_func_t
{
print_version_and_exit
}};
clapp
::
value
::
found_func_t
{
print_version_and_exit
},
purpose_t
::
optional
};
clapp
::
count_option_t
verbose
{
*
this
,
"verbose"
,
'v'
,
"Verbose option."
,
clapp
::
min_max_value_t
<
std
::
size_t
>
{
0
,
7
},
clapp
::
default_value_t
<
std
::
size_t
>
{
2
}};
clapp
::
default_value_t
<
std
::
size_t
>
{
2
},
purpose_t
::
optional
};
clapp
::
bool_option_t
debug
{
*
this
,
"debug"
,
'd'
,
"debug option."
,
clapp
::
value
::
found_func_t
{
print_not_implemented_and_exit
}};
*
this
,
"debug"
,
'd'
,
"debug option."
,
clapp
::
value
::
found_func_t
{
print_not_implemented_and_exit
},
purpose_t
::
optional
};
// create a subparser with a registered help option
class
sub_parser_t
:
public
clapp
::
basic_sub_parser_t
{
...
...
@@ -58,7 +65,8 @@ class cli_parser_t : public clapp::basic_main_parser_t {
~
sub_parser_t
()
override
;
clapp
::
help_option_t
help
{
*
this
,
"help"
,
'h'
,
"Show help options."
};
clapp
::
help_option_t
help
{
*
this
,
"help"
,
'h'
,
"Show help options."
,
purpose_t
::
optional
};
};
// first subparser declaration (inherits help from sub_parser_t)
...
...
@@ -78,9 +86,10 @@ class cli_parser_t : public clapp::basic_main_parser_t {
clapp
::
double_param_option_t
double_opt
{
*
this
,
'd'
,
"Double param option"
,
clapp
::
default_value_t
<
double
>
{
10
}};
clapp
::
default_value_t
<
double
>
{
10
}
,
purpose_t
::
optional
};
clapp
::
string_param_option_t
string
{
*
this
,
's'
,
"String param option."
};
clapp
::
string_param_option_t
string
{
*
this
,
's'
,
"String param option."
,
purpose_t
::
optional
};
clapp
::
string_argument_t
string_arg_x
{
*
this
,
"string-arg-x"
,
"String argument x"
,
purpose_t
::
optional
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment