diff --git a/tests/functional/run-tests b/tests/functional/run-tests index cbfe587f..eebd0ea7 100755 --- a/tests/functional/run-tests +++ b/tests/functional/run-tests @@ -16,7 +16,7 @@ mkdir -p "$PWD" # Prepare toml # Generate new config file. -cargo run -- -V -b -c "$PWD/tpnote.toml" +cargo run -- -C "$PWD/tpnote.toml" # Remove all `date` lines of all templates. TP_NOTE_TEST_TOML="$PWD/tpnote-tmp.toml" grep -v -e "key='fm_date'" "$PWD/tpnote.toml" > "$TP_NOTE_TEST_TOML" diff --git a/tests/functional/run-tests2 b/tests/functional/run-tests2 index 64101ac2..157bfd76 100755 --- a/tests/functional/run-tests2 +++ b/tests/functional/run-tests2 @@ -18,7 +18,7 @@ mkdir -p "$PWD" # Prepare toml # Generate new config file. -cargo run -- -V -b -c "$PWD/tpnote.toml" >/dev/null 2>&1 +cargo run -- -C "$PWD/tpnote.toml" # Remove all `date` lines of all templates. TP_NOTE_TEST_TOML="$PWD/tpnote-tmp.toml" grep -v -e "key='fm_date'" "$PWD/tpnote.toml" > "$TP_NOTE_TEST_TOML" diff --git a/tpnote/src/error.rs b/tpnote/src/error.rs index ce7a7b8d..1d04900b 100644 --- a/tpnote/src/error.rs +++ b/tpnote/src/error.rs @@ -53,7 +53,7 @@ pub enum ConfigFileError { /// Remedy: check the path and permissions of the to be generated /// configuration file. #[error( - "Unable write a configuration file with default values:\n\ + "Can not write the default configuration:\n\ ---\n\ {error}" )] @@ -61,7 +61,7 @@ pub enum ConfigFileError { /// Remedy: restart, or check file permission of the configuration file. #[error( - "Unable to load or parse the (merged)\n\ + "Can not load or parse the (merged)\n\ configuration file(s):\n\ ---\n\ {error}\n\n\ diff --git a/tpnote/src/main.rs b/tpnote/src/main.rs index 4a8e54a2..82dd3a04 100644 --- a/tpnote/src/main.rs +++ b/tpnote/src/main.rs @@ -154,24 +154,24 @@ fn main() { }; }; - // Process `arg = `--config`. - // The output is YAML formatted for further automatic processing. - if ARGS.batch && ARGS.version && ARGS.debug.is_none() { - if let Some(path) = &ARGS.config { - let path = Path::new(&path); + // Process `arg = `--default-config`. + if let Some(path) = &ARGS.config_defaults { + let path = Path::new(&path); - if let Err(e) = Cfg::write_default_to_file(path) { - log::error!( - "{}", - ConfigFileError::ConfigFileWrite { - error: e.to_string() - } - .to_string() - ); - AppLogger::flush(); - process::exit(5); - }; - } + if let Err(e) = Cfg::write_default_to_file(path) { + log::error!( + "{}", + ConfigFileError::ConfigFileWrite { + error: e.to_string() + } + .to_string() + ); + AppLogger::flush(); + process::exit(5); + }; + // Exit. + AppLogger::flush(); + process::exit(0); } // Process `arg = `--version`. diff --git a/tpnote/src/settings.rs b/tpnote/src/settings.rs index 864713ff..e0171ad6 100644 --- a/tpnote/src/settings.rs +++ b/tpnote/src/settings.rs @@ -63,10 +63,14 @@ pub struct Args { /// Batch mode: does not launch editor or viewer #[structopt(long, short = "b")] pub batch: bool, - /// Loads an additional configuration file or writes default + /// Loads (and merges) an additional configuration file #[structopt(long, short = "c")] pub config: Option, - /// Console debug level: "trace", "debug", "info", "warn", "error" (default) or "off" + /// Dumps the internal default configuration into a file + #[structopt(long, short = "C")] + pub config_defaults: Option, + /// Console debug level: "trace", "debug", "info", "warn", "error" + /// (default) or "off" #[structopt(long, short = "d")] pub debug: Option, /// Shows console debug messages also as popup windows @@ -75,7 +79,7 @@ pub struct Args { /// Launches only the editor, no browser #[structopt(long, short = "e")] pub edit: bool, - /// Scheme for new notes: "default", "zettel", (see config. for more) + /// Scheme for new notes: "default", "zettel", (cf. `--config-defaults`) #[structopt(long, short = "s")] pub scheme: Option, /// Forces console mode: opens console editor, no browser @@ -87,8 +91,8 @@ pub struct Args { /// Disables filename synchronization #[structopt(long, short = "n")] pub no_filename_sync: bool, - /// Disables the automatic language detection and uses `` instead; - /// or, if `` use `TPNOTE_LANG` or `LANG` + /// Disables the automatic language detection and uses `` + /// instead; or, if `` use `TPNOTE_LANG` or `LANG` #[structopt(long, short = "l")] pub force_lang: Option, /// Launches only the browser, no editor