From ae2526b93fbca25f179f41f618d8cc4335d338d5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 8 Jun 2021 19:09:25 +0100 Subject: [PATCH] otter cli: Add --no-prefs option This saves the user using --prefs /dev/null. Signed-off-by: Ian Jackson --- cli/otter.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/otter.rs b/cli/otter.rs index f76f2d06..51c78fec 100644 --- a/cli/otter.rs +++ b/cli/otter.rs @@ -218,9 +218,13 @@ fn main() { (shell syntax, interpreted by the remote shell)", default_ssh_proxy_command())))); - ap.refer(&mut rma.prefs_path) + let mut prefs_path = ap.refer(&mut rma.prefs_path); + prefs_path .add_option(&["--prefs"], StoreOption, "preferences file (usually ~/.config/otter/prefs.toml)"); + prefs_path + .add_option(&["--no-prefs"], StoreConst(Some("/dev/null".to_owned())), + "do not read any preferences file"); ap.refer(&mut rma.spec_dir) .add_option(&["--spec-dir"], StoreOption, @@ -365,6 +369,9 @@ option values; or`true` and `false` for just --option or --no-option. }) .context("locate preferences file (prefs.toml)")?; + // shortcut this mostly for portability + if prefs_path == PathBuf::from(&"/dev/null") { return Ok(()) } + let data: Option = (||{ let data = match fs::read_to_string(&prefs_path) { Err(e) if e.kind() == ErrorKind::NotFound => { -- 2.30.2