From: Ian Jackson Date: Tue, 8 Jun 2021 18:09:25 +0000 (+0100) Subject: otter cli: Add --no-prefs option X-Git-Tag: otter-0.7.0~5 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ae2526b93fbca25f179f41f618d8cc4335d338d5;p=otter.git otter cli: Add --no-prefs option This saves the user using --prefs /dev/null. Signed-off-by: Ian Jackson --- 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 => {