Skip to content

Commit

Permalink
Promote special CLI rules to flags (#495)
Browse files Browse the repository at this point in the history
* Promote special CLI rules to flags.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Improve argument parsing logging and error messages.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Remove some short form CLI flags.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic authored Sep 12, 2019
1 parent 40a276b commit e8bbb75
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 183 deletions.
15 changes: 8 additions & 7 deletions rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ typedef struct rcl_arguments_t
#define RCL_ROS_ARGS_EXPLICIT_END_TOKEN "--"
#define RCL_PARAM_FLAG "--param"
#define RCL_SHORT_PARAM_FLAG "-p"
#define RCL_PARAM_FILE_FLAG "--params-file"
#define RCL_REMAP_FLAG "--remap"
#define RCL_SHORT_REMAP_FLAG "-r"
#define RCL_LOG_LEVEL_FLAG "--log-level"
#define RCL_EXTERNAL_LOG_CONFIG_FLAG "--log-config-file"
// To be prefixed with --enable- or --disable-
#define RCL_LOG_STDOUT_FLAG_SUFFIX "stdout-logs"
#define RCL_LOG_ROSOUT_FLAG_SUFFIX "rosout-logs"
#define RCL_LOG_EXT_LIB_FLAG_SUFFIX "external-lib-logs"

#define RCL_LOG_LEVEL_ARG_RULE "__log_level:="
#define RCL_EXTERNAL_LOG_CONFIG_ARG_RULE "__log_config_file:="
#define RCL_LOG_DISABLE_STDOUT_ARG_RULE "__log_disable_stdout:="
#define RCL_LOG_DISABLE_ROSOUT_ARG_RULE "__log_disable_rosout:="
#define RCL_LOG_DISABLE_EXT_LIB_ARG_RULE "__log_disable_external_lib:="
#define RCL_PARAM_FILE_ARG_RULE "__params:="

/// Return a rcl_arguments_t struct with members initialized to `NULL`.
RCL_PUBLIC
Expand Down Expand Up @@ -75,7 +76,7 @@ rcl_get_zero_initialized_arguments(void);
* Parameter override rule parsing is supported via `-p/--param` flags e.g. `--param name:=value`
* or `-p name:=value`.
*
* The default log level will be parsed as `__log_level:=level`, where `level` is a name
* The default log level will be parsed as `--log-level level`, where `level` is a name
* representing one of the log levels in the `RCUTILS_LOG_SEVERITY` enum, e.g. `info`, `debug`,
* `warn`, not case sensitive.
* If multiple of these rules are found, the last one parsed will be used.
Expand Down
2 changes: 1 addition & 1 deletion rcl/include/rcl/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ typedef rmw_ret_t rcl_ret_t;
/// Argument is not a valid parameter rule
#define RCL_RET_INVALID_PARAM_RULE 1010
/// Argument is not a valid log level rule
#define RCL_RET_INVALID_LOG_LEVEL_RULE 1020
#define RCL_RET_INVALID_LOG_LEVEL 1020

// rcl event specific ret codes in 20XX
/// Invalid rcl_event_t given return code.
Expand Down
Loading

0 comments on commit e8bbb75

Please sign in to comment.