summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-20 18:36:31 +0200
committerGitHub <noreply@github.com>2017-09-20 18:36:31 +0200
commite7ec39bdcc7b9e0b372efcc17ec19d977bd73921 (patch)
tree8270ef4aff894f2583812fe15b5789a200710f75
parent4b906f27b1e11f2fec64b06dae5f4a258976da68 (diff)
parente0009577223ee0aa9a86be0be8514fb178db0c94 (diff)
downloadimag-e7ec39bdcc7b9e0b372efcc17ec19d977bd73921.zip
imag-e7ec39bdcc7b9e0b372efcc17ec19d977bd73921.tar.gz
Merge pull request #1089 from matthiasbeyer/imag-bin/pass-runtime-generated-args
Ensure that all arguments are passed to the subcommand
-rw-r--r--bin/core/imag/src/main.rs57
-rw-r--r--doc/src/09020-changelog.md2
2 files changed, 56 insertions, 3 deletions
diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs
index f6ae33f..3cd21ee 100644
--- a/bin/core/imag/src/main.rs
+++ b/bin/core/imag/src/main.rs
@@ -35,7 +35,7 @@ use std::io::ErrorKind;
use std::collections::BTreeMap;
use walkdir::WalkDir;
-use clap::{Arg, AppSettings, SubCommand};
+use clap::{Arg, ArgMatches, AppSettings, SubCommand};
use toml::Value;
use toml_query::read::TomlValueReadExt;
@@ -197,11 +197,13 @@ fn main() {
// Get all given arguments and further subcommands to pass to
// the imag-<> binary
// Providing no arguments is OK, and is therefore ignored here
- let subcommand_args : Vec<&str> = match scmd.values_of("") {
- Some(values) => values.collect(),
+ let mut subcommand_args : Vec<String> = match scmd.values_of("") {
+ Some(values) => values.map(String::from).collect(),
None => Vec::new()
};
+ forward_commandline_arguments(&matches, &mut subcommand_args);
+
let subcommand = String::from(subcommand);
let subcommand = aliases.get(&subcommand).cloned().unwrap_or(subcommand);
@@ -296,3 +298,52 @@ fn fetch_aliases(rt: &Runtime) -> Result<BTreeMap<String, String>, String> {
}
}
+fn forward_commandline_arguments(m: &ArgMatches, scmd: &mut Vec<String>) {
+ let push = |flag: Option<&str>, val_name: &str, m: &ArgMatches, v: &mut Vec<String>| {
+ let _ = m
+ .value_of(val_name)
+ .map(|val| {
+ let flag = format!("--{}", flag.unwrap_or(val_name));
+ v.insert(0, String::from(val));
+ v.insert(0, flag);
+ });
+ };
+
+ push(Some("verbose"),
+ Runtime::arg_verbosity_name(), m , scmd);
+
+ push(Some("debug"),
+ Runtime::arg_debugging_name(), m , scmd);
+
+ push(Some("no-color"),
+ Runtime::arg_no_color_output_name(), m , scmd);
+
+ push(Some("config"),
+ Runtime::arg_config_name(), m , scmd);
+
+ push(Some("override-config"),
+ Runtime::arg_config_override_name(), m , scmd);
+
+ push(Some("rtp"),
+ Runtime::arg_runtimepath_name(), m , scmd);
+
+ push(Some("store"),
+ Runtime::arg_storepath_name(), m , scmd);
+
+ push(Some("editor"),
+ Runtime::arg_editor_name(), m , scmd);
+
+ push(Some("generate-commandline-completion"),
+ Runtime::arg_generate_compl(), m , scmd);
+
+ push(None , Runtime::arg_logdest_name() , m , scmd);
+ push(None , Runtime::arg_override_module_logging_setting_name() , m , scmd);
+ push(None , Runtime::arg_override_trace_logging_format() , m , scmd);
+ push(None , Runtime::arg_override_debug_logging_format() , m , scmd);
+ push(None , Runtime::arg_override_info_logging_format() , m , scmd);
+ push(None , Runtime::arg_override_warn_logging_format() , m , scmd);
+ push(None , Runtime::arg_override_error_logging_format() , m , scmd);
+
+
+}
+
diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md
index b1bbde8..469f634 100644
--- a/doc/src/09020-changelog.md
+++ b/doc/src/09020-changelog.md
@@ -35,6 +35,8 @@ This section contains the changelog from the last release to the next release.
* New
* `libimagentrygps` was introduced
* `imag-grep` was introduced
+ * The `imag` command now passes all arguments properly to the called
+ subcommand
* Fixed bugs
* The config loading in `libimagrt`
[was fixed](http://git.imag-pim.org/imag/commit/?id=9193d50f96bce099665d2eb716bcaa29a8d9b8ff).