diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-07 10:01:26 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-07 10:08:27 +0100 |
commit | 26f8b25c111c0b5c87b0cd87ad11b6bf24f22e35 (patch) | |
tree | a73415a86909b6472b64ea10659770d7fe2e5290 /tool | |
parent | 4c61e4c5caa421ace06733630bda85b19579946a (diff) |
tool: Drop dependency on promptly.
- Do not ask whether to overwrite files, just fail and mention
--force.
- We decided that sq should not be interactive (modulo password
prompts). Interactive programs are more difficult to test and
script. Furthermore, it turns out that nix, a dependency of
promptly, does not build on Android.
- Fixes #148.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/Cargo.toml | 1 | ||||
-rw-r--r-- | tool/src/sq.rs | 12 | ||||
-rw-r--r-- | tool/src/sq_cli.rs | 2 |
3 files changed, 4 insertions, 11 deletions
diff --git a/tool/Cargo.toml b/tool/Cargo.toml index 9d55e381..7fd56ac2 100644 --- a/tool/Cargo.toml +++ b/tool/Cargo.toml @@ -31,7 +31,6 @@ prettytable-rs = "0.8.0" rpassword = "2.0.0" tempfile = "3.0.4" time = "0.1.38" -promptly = "0.1.5" [build-dependencies] clap = "2.27.1" diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 244fecf9..d70d9d10 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -7,7 +7,6 @@ extern crate prettytable; extern crate rpassword; extern crate tempfile; extern crate time; -extern crate promptly; use failure::ResultExt; use prettytable::{Table, Cell, Row}; @@ -41,17 +40,12 @@ fn open_or_stdin(f: Option<&str>) -> Result<Box<io::Read>, failure::Error> { fn create_or_stdout(f: Option<&str>, force: bool) -> Result<Box<io::Write>, failure::Error> { - use promptly::prompt_default; - match f { None => Ok(Box::new(io::stdout())), Some(p) if p == "-" => Ok(Box::new(io::stdout())), Some(f) => { let p = Path::new(f); - let path_ok = force || !p.exists() || - prompt_default(format!("{} exists already. Overwrite?", f), false); - - if path_ok { + if !p.exists() || force { Ok(Box::new(OpenOptions::new() .write(true) .truncate(true) @@ -59,8 +53,8 @@ fn create_or_stdout(f: Option<&str>, force: bool) .open(f) .context("Failed to create output file")?)) } else { - eprintln!("Cannot continue"); - exit(1); + Err(failure::err_msg( + format!("File {:?} exists, use --force to overwrite", p))) } } } diff --git a/tool/src/sq_cli.rs b/tool/src/sq_cli.rs index 78a9b484..b44403fc 100644 --- a/tool/src/sq_cli.rs +++ b/tool/src/sq_cli.rs @@ -29,7 +29,7 @@ pub fn build() -> App<'static, 'static> { .arg(Arg::with_name("force") .long("force") .short("f") - .help("Overwrite files without asking")) + .help("Overwrite existing files")) .subcommand(SubCommand::with_name("decrypt") .display_order(10) .about("Decrypts an OpenPGP message") |