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
7d4b00fa
Commit
7d4b00fa
authored
Jun 21, 2017
by
Sebastian Woelke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow chaining of CLI argument remainders
parent
438784fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+3
-3
libcaf_core/test/message.cpp
libcaf_core/test/message.cpp
+13
-1
No files found.
libcaf_core/src/message.cpp
View file @
7d4b00fa
...
...
@@ -239,12 +239,13 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs,
bool
skip_remainder
=
false
;
auto
res
=
extract
({
[
&
](
const
std
::
string
&
arg
)
->
optional
<
skip_t
>
{
if
(
skip_remainder
)
return
skip
();
if
(
arg
==
"--"
)
{
skip_remainder
=
true
;
// drop frist remainder indicator
return
none
;
}
if
(
skip_remainder
)
return
skip
();
if
(
arg
.
empty
()
||
arg
.
front
()
!=
'-'
)
{
return
skip
();
}
...
...
@@ -295,7 +296,6 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs,
[
&
](
const
std
::
string
&
arg1
,
const
std
::
string
&
arg2
)
->
optional
<
skip_t
>
{
if
(
arg1
==
"--"
)
{
skip_remainder
=
true
;
return
skip
();
}
if
(
skip_remainder
)
...
...
libcaf_core/test/message.cpp
View file @
7d4b00fa
...
...
@@ -130,13 +130,25 @@ CAF_TEST(extract_opts) {
f
({
"-f"
,
"hello.txt"
,
"-l5"
},
{});
f
({
"-fhello.txt"
,
"-l"
,
"5"
},
{});
f
({
"-l5"
,
"-fhello.txt"
},
{});
// on remainder
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"a"
},
{
"a"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"a"
,
"b"
},
{
"a"
,
"b"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"aa"
,
"bb"
},
{
"aa"
,
"bb"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"-a"
,
"--bb"
},
{
"-a"
,
"--bb"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"-a1"
,
"--bb=10"
},
{
"-a1"
,
"--bb=10"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"-a 1"
,
"--b=10"
},
{
"-a 1"
,
"--b=10"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"-a 1"
,
"--b=10"
},
{
"-a 1"
,
"--b=10"
});
// multiple remainders
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"a"
,
"--"
},
{
"a"
,
"--"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"a"
,
"--"
,
"--"
},
{
"a"
,
"--"
,
"--"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"a"
,
"--"
,
"b"
},
{
"a"
,
"--"
,
"b"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"aa"
,
"--"
,
"bb"
},
{
"aa"
,
"--"
,
"bb"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"aa"
,
"--"
,
"--"
,
"bb"
},
{
"aa"
,
"--"
,
"--"
,
"bb"
});
f
({
"--file=hello.txt"
,
"-l"
,
"5"
,
"--"
,
"--"
,
"--"
,
"-a1"
,
"--bb=10"
},
{
"--"
,
"--"
,
"-a1"
,
"--bb=10"
});
CAF_MESSAGE
(
"ensure that failed parsing doesn't consume input"
);
auto
msg
=
make_message
(
"-f"
,
"42"
,
"-b"
,
"1337"
);
auto
foo
=
0
;
...
...
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