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
a5cc03ee
Commit
a5cc03ee
authored
Jun 16, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only exclude CAF options from --help output
parent
7d2cbd0e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
CHANGELOG.md
CHANGELOG.md
+7
-0
libcaf_core/caf/config_option_set.hpp
libcaf_core/caf/config_option_set.hpp
+1
-1
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+2
-1
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+10
-6
No files found.
CHANGELOG.md
View file @
a5cc03ee
...
...
@@ -6,6 +6,13 @@ is based on [Keep a Changelog](https://keepachangelog.com).
## [Unreleased]
### Changed
-
When using CAF to parse CLI arguments, the output of
`--help`
now includes all
user-defined options. Previously, only options in the global category or
options with a short name were included. Only CAF options are now excluded
from the output. They will still be included in the output of
`--long-help`
.
### Fixed
-
Fix build errors with exceptions disabled.
...
...
libcaf_core/caf/config_option_set.hpp
View file @
a5cc03ee
...
...
@@ -158,7 +158,7 @@ public:
config_option_set
&
add
(
config_option
opt
);
/// Generates human-readable help text for all options.
std
::
string
help_text
(
bool
global_only
=
true
)
const
;
std
::
string
help_text
(
bool
hide_caf_options
=
true
)
const
;
/// Drops all options.
void
clear
()
{
...
...
libcaf_core/src/actor_system_config.cpp
View file @
a5cc03ee
...
...
@@ -47,7 +47,8 @@ actor_system_config::actor_system_config()
using
string_list
=
std
::
vector
<
string
>
;
opt_group
{
custom_options_
,
"global"
}
.
add
<
bool
>
(
"help,h?"
,
"print help text to STDERR and exit"
)
.
add
<
bool
>
(
"long-help"
,
"print long help text to STDERR and exit"
)
.
add
<
bool
>
(
"long-help"
,
"same as --help but list options that are omitted by default"
)
.
add
<
bool
>
(
"dump-config"
,
"print configuration to STDERR and exit"
)
.
add
<
string
>
(
"config-file"
,
"sets a path to a configuration file"
);
opt_group
{
custom_options_
,
"caf.scheduler"
}
...
...
libcaf_core/src/config_option_set.cpp
View file @
a5cc03ee
...
...
@@ -43,7 +43,7 @@ config_option_set& config_option_set::add(config_option opt) {
return
*
this
;
}
std
::
string
config_option_set
::
help_text
(
bool
global_only
)
const
{
std
::
string
config_option_set
::
help_text
(
bool
hide_caf_options
)
const
{
// <--- argument --------> <---- description --->
// (-w|--write) <string> : output file
auto
build_argument
=
[](
const
config_option
&
x
)
{
...
...
@@ -68,6 +68,10 @@ std::string config_option_set::help_text(bool global_only) const {
sb
<<
"<"
<<
x
.
type_name
()
<<
'>'
;
return
std
::
move
(
sb
.
result
);
};
// Utility function for checking whether a category is a CAF option.
auto
is_caf_option
=
[](
std
::
string_view
category
)
{
return
category
==
"caf"
||
starts_with
(
category
,
"caf."
);
};
// Sort argument + description by category.
using
pair
=
std
::
pair
<
std
::
string
,
option_pointer
>
;
std
::
set
<
std
::
string_view
>
categories
;
...
...
@@ -75,12 +79,12 @@ std::string config_option_set::help_text(bool global_only) const {
size_t
max_arg_size
=
0
;
for
(
auto
&
opt
:
opts_
)
{
// We treat all options with flat name as-if the category was 'global'.
if
(
!
global_only
||
opt
.
has_flat_cli_name
())
{
auto
arg
=
build_argument
(
opt
);
max_arg_size
=
std
::
max
(
max_arg_size
,
arg
.
size
());
std
::
string_view
category
=
"global"
;
if
(
!
opt
.
has_flat_cli_name
())
category
=
opt
.
category
();
if
(
!
hide_caf_options
||
!
is_caf_option
(
category
))
{
max_arg_size
=
std
::
max
(
max_arg_size
,
arg
.
size
());
categories
.
emplace
(
category
);
args
.
emplace
(
category
,
std
::
make_pair
(
std
::
move
(
arg
),
&
opt
));
}
...
...
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