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
d8e5811e
Commit
d8e5811e
authored
Mar 13, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `message::extract_opts` for opts w/o arguments
parent
db51f7e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+13
-6
No files found.
libcaf_core/src/message.cpp
View file @
d8e5811e
...
@@ -179,6 +179,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
...
@@ -179,6 +179,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
auto
i
=
shorts
.
find
(
arg
);
auto
i
=
shorts
.
find
(
arg
);
if
(
i
!=
shorts
.
end
())
{
if
(
i
!=
shorts
.
end
())
{
if
(
i
->
second
->
fun
)
{
if
(
i
->
second
->
fun
)
{
// this short opt expects two arguments
return
skip_message
();
return
skip_message
();
}
}
insert_opt_name
(
i
->
second
);
insert_opt_name
(
i
->
second
);
...
@@ -212,7 +213,13 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
...
@@ -212,7 +213,13 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
return
skip_message
();
return
skip_message
();
}
}
auto
i
=
shorts
.
find
(
arg1
);
auto
i
=
shorts
.
find
(
arg1
);
if
(
i
!=
shorts
.
end
()
&&
i
->
second
->
fun
)
{
if
(
i
!=
shorts
.
end
())
{
if
(
!
i
->
second
->
fun
)
{
// this short opt does not expect an argument,
// tell extract to try this option again with one
// less argument
return
skip_message
();
}
if
(
!
i
->
second
->
fun
(
arg2
))
{
if
(
!
i
->
second
->
fun
(
arg2
))
{
std
::
cerr
<<
"invalid value for option "
std
::
cerr
<<
"invalid value for option "
<<
i
->
second
->
name
<<
": "
<<
arg2
<<
std
::
endl
;
<<
i
->
second
->
name
<<
": "
<<
arg2
<<
std
::
endl
;
...
@@ -226,14 +233,14 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
...
@@ -226,14 +233,14 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs) const {
}
}
});
});
size_t
name_width
=
0
;
size_t
name_width
=
0
;
for
(
auto
&
ca
:
xs
)
{
for
(
auto
&
x
:
xs
)
{
// name field contains either only "--<long_name>" or
// name field contains either only "--<long_name>" or
// "-<short name> [--<long name>]" depending on whether or not
// "-<short name> [--<long name>]" depending on whether or not
// a ',' appears in the name
// a ',' appears in the name
auto
nw
=
ca
.
name
.
find
(
','
)
==
std
::
string
::
npos
auto
nw
=
x
.
name
.
find
(
','
)
==
std
::
string
::
npos
?
ca
.
name
.
size
()
+
2
// "--<name>"
?
x
.
name
.
size
()
+
2
// "--<name>"
:
ca
.
name
.
size
()
+
5
;
// "-X [--<name>]" (minus trailing ",X")
:
x
.
name
.
size
()
+
5
;
// "-X [--<name>]" (minus trailing ",X")
if
(
ca
.
fun
)
{
if
(
x
.
fun
)
{
nw
+=
4
;
// trailing " arg"
nw
+=
4
;
// trailing " arg"
}
}
name_width
=
std
::
max
(
name_width
,
nw
);
name_width
=
std
::
max
(
name_width
,
nw
);
...
...
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