Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
3c15db6a
Commit
3c15db6a
authored
Nov 05, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed output of help text for program options
parent
55484684
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
cppa/opt.hpp
cppa/opt.hpp
+6
-1
src/opt.cpp
src/opt.cpp
+21
-5
No files found.
cppa/opt.hpp
View file @
3c15db6a
...
...
@@ -59,7 +59,12 @@ detail::add_arg_functor<T> add_arg(std::vector<T>& storage) {
return
{
storage
};
}
typedef
std
::
map
<
std
::
string
,
std
::
map
<
std
::
pair
<
char
,
std
::
string
>
,
std
::
string
>
>
struct
option_info
{
std
::
string
help_text
;
size_t
num_args
;
};
typedef
std
::
map
<
std
::
string
,
std
::
map
<
std
::
pair
<
char
,
std
::
string
>
,
option_info
>
>
options_description
;
detail
::
opt_rvalue_builder
<
true
>
on_opt
(
char
short_opt
,
...
...
src/opt.cpp
View file @
3c15db6a
...
...
@@ -43,7 +43,8 @@ detail::opt_rvalue_builder<true> on_opt(char short_opt,
string
help_text
,
string
help_group
)
{
if
(
desc
)
{
(
*
desc
)[
help_group
].
insert
(
make_pair
(
make_pair
(
short_opt
,
long_opt
),
help_text
));
option_info
oinf
{
help_text
,
1
};
(
*
desc
)[
help_group
].
insert
(
make_pair
(
make_pair
(
short_opt
,
long_opt
),
move
(
oinf
)));
}
const
char
short_flag_arr
[]
=
{
'-'
,
short_opt
,
'\0'
};
const
char
*
lhs_str
=
short_flag_arr
;
...
...
@@ -73,7 +74,8 @@ on_vopt(char short_opt,
string
help_text
,
string
help_group
)
{
if
(
desc
)
{
(
*
desc
)[
help_group
].
insert
(
make_pair
(
make_pair
(
short_opt
,
long_opt
),
help_text
));
option_info
oinf
{
help_text
,
0
};
(
*
desc
)[
help_group
].
insert
(
make_pair
(
make_pair
(
short_opt
,
long_opt
),
move
(
oinf
)));
}
const
char
short_flag_arr
[]
=
{
'-'
,
short_opt
,
'\0'
};
vector
<
string
>
opt_strs
=
{
short_flag_arr
};
...
...
@@ -85,6 +87,10 @@ on_vopt(char short_opt,
function
<
void
()
>
print_desc
(
options_description
*
desc
,
ostream
&
out
)
{
return
[
&
out
,
desc
]
{
if
(
!
desc
)
return
;
if
(
desc
->
empty
())
{
out
<<
"please use '-h' or '--help' for a list "
"of available program options
\n
"
;
}
for
(
auto
&
opt_group
:
*
desc
)
{
out
<<
opt_group
.
first
<<
":
\n
"
;
for
(
auto
&
opt
:
opt_group
.
second
)
{
...
...
@@ -93,10 +99,20 @@ function<void()> print_desc(options_description* desc, ostream& out) {
ostringstream
tmp
;
auto
&
names
=
opt
.
first
;
if
(
names
.
first
!=
'\0'
)
{
tmp
<<
"-"
<<
names
.
first
<<
" <arg> | "
;
tmp
<<
"-"
<<
names
.
first
;
for
(
size_t
num
=
1
;
num
<=
opt
.
second
.
num_args
;
++
num
)
{
tmp
<<
" <arg"
<<
num
<<
">"
;
}
tmp
<<
" | "
;
}
tmp
<<
"--"
<<
names
.
second
;
if
(
opt
.
second
.
num_args
>
0
)
{
tmp
<<
"=<arg1>"
;
}
for
(
size_t
num
=
2
;
num
<=
opt
.
second
.
num_args
;
++
num
)
{
tmp
<<
",<arg"
<<
num
<<
">"
;
}
tmp
<<
"--"
<<
names
.
second
<<
" <arg>"
;
out
<<
tmp
.
str
()
<<
opt
.
second
<<
"
\n
"
;
out
<<
tmp
.
str
()
<<
opt
.
second
.
help_text
<<
"
\n
"
;
}
out
<<
"
\n
"
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment