TUI: Use rage binary in example commands if installed

This commit is contained in:
Jack Grigg
2021-05-02 09:23:58 +12:00
parent 458a09125f
commit ba3ccda8ce
3 changed files with 29 additions and 2 deletions
+11 -2
View File
@@ -551,6 +551,9 @@ fn main() -> Result<(), Error> {
writeln!(file, "# Recipient: {}", recipient)?;
writeln!(file, "{}", stub.to_string())?;
// If `rage` binary is installed, use it in examples. Otherwise default to `age`.
let age_binary = which::which("rage").map(|_| "rage").unwrap_or("age");
eprintln!();
eprintln!("✅ Done! This YubiKey identity is ready to go.");
eprintln!();
@@ -564,10 +567,16 @@ fn main() -> Result<(), Error> {
eprintln!("Here are some example things you can do with it:");
eprintln!();
eprintln!("- Encrypt a file to this identity:");
eprintln!(" $ cat foo.txt | age -r {} -o foo.txt.age", recipient);
eprintln!(
" $ cat foo.txt | {} -r {} -o foo.txt.age",
age_binary, recipient
);
eprintln!();
eprintln!("- Decrypt a file with this identity:");
eprintln!(" $ cat foo.txt.age | age -d -i {} > foo.txt", file_name);
eprintln!(
" $ cat foo.txt.age | {} -d -i {} > foo.txt",
age_binary, file_name
);
eprintln!();
eprintln!("- Recreate the identity file:");
eprintln!(