From 4ff5e01ae932649910d645d947cc94ca006ca09e Mon Sep 17 00:00:00 2001 From: Stefan Gehr Date: Fri, 9 Aug 2024 11:03:56 +0200 Subject: [PATCH 1/5] add value hints to rage completions --- rage/src/bin/rage/cli.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rage/src/bin/rage/cli.rs b/rage/src/bin/rage/cli.rs index d01c7f46..25a7a4f4 100644 --- a/rage/src/bin/rage/cli.rs +++ b/rage/src/bin/rage/cli.rs @@ -1,6 +1,6 @@ use std::path::Path; -use clap::{builder::Styles, ArgAction, Parser}; +use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; use crate::fl; @@ -99,6 +99,7 @@ pub(crate) struct AgeOptions { #[arg(help_heading = fl!("args-header"))] #[arg(value_name = fl!("input"))] #[arg(help = fl!("help-arg-input"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) input: Option, #[arg(action = ArgAction::Help, short, long)] @@ -137,11 +138,13 @@ pub(crate) struct AgeOptions { #[arg(short = 'R', long)] #[arg(value_name = fl!("recipients-file"))] #[arg(help = fl!("help-flag-recipients-file"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) recipients_file: Vec, #[arg(short, long)] #[arg(value_name = fl!("identity"))] #[arg(help = fl!("help-flag-identity"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) identity: Vec, #[arg(short = 'j')] @@ -152,5 +155,6 @@ pub(crate) struct AgeOptions { #[arg(short, long)] #[arg(value_name = fl!("output"))] #[arg(help = fl!("help-flag-output"))] + #[arg(value_hint = ValueHint::AnyPath)] pub(crate) output: Option, } From daf0829142b4200f1dc9c376c8d24a6392ad858a Mon Sep 17 00:00:00 2001 From: Stefan Gehr Date: Fri, 9 Aug 2024 11:13:21 +0200 Subject: [PATCH 2/5] add value hints to rage-keygen completions --- rage/src/bin/rage-keygen/cli.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rage/src/bin/rage-keygen/cli.rs b/rage/src/bin/rage-keygen/cli.rs index fe07d08b..66837c48 100644 --- a/rage/src/bin/rage-keygen/cli.rs +++ b/rage/src/bin/rage-keygen/cli.rs @@ -1,4 +1,4 @@ -use clap::{builder::Styles, ArgAction, Parser}; +use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; use crate::fl; @@ -22,6 +22,7 @@ pub(crate) struct AgeOptions { #[arg(help_heading = fl!("args-header"))] #[arg(value_name = fl!("input"))] #[arg(help = fl!("help-arg-input"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) input: Option, #[arg(action = ArgAction::Help, short, long)] @@ -35,6 +36,7 @@ pub(crate) struct AgeOptions { #[arg(short, long)] #[arg(value_name = fl!("output"))] #[arg(help = fl!("keygen-help-flag-output"))] + #[arg(value_hint = ValueHint::AnyPath)] pub(crate) output: Option, #[arg(short = 'y')] From 26ebfbfc880fbf205315a56cfadcda00b4c5db70 Mon Sep 17 00:00:00 2001 From: Stefan Gehr Date: Fri, 9 Aug 2024 11:13:30 +0200 Subject: [PATCH 3/5] add value hints to rage-mount completions --- rage/src/bin/rage-mount/cli.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rage/src/bin/rage-mount/cli.rs b/rage/src/bin/rage-mount/cli.rs index 0cb65dba..9f82d568 100644 --- a/rage/src/bin/rage-mount/cli.rs +++ b/rage/src/bin/rage-mount/cli.rs @@ -1,4 +1,4 @@ -use clap::{builder::Styles, ArgAction, Parser}; +use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; use crate::fl; @@ -24,11 +24,13 @@ pub(crate) struct AgeMountOptions { #[arg(help_heading = fl!("args-header"))] #[arg(value_name = fl!("mnt-filename"))] #[arg(help = fl!("help-arg-mnt-filename"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) filename: String, #[arg(help_heading = fl!("args-header"))] #[arg(value_name = fl!("mnt-mountpoint"))] #[arg(help = fl!("help-arg-mnt-mountpoint"))] + #[arg(value_hint = ValueHint::DirPath)] pub(crate) mountpoint: String, #[arg(action = ArgAction::Help, short, long)] @@ -51,5 +53,6 @@ pub(crate) struct AgeMountOptions { #[arg(short, long)] #[arg(value_name = fl!("identity"))] #[arg(help = fl!("help-flag-identity"))] + #[arg(value_hint = ValueHint::FilePath)] pub(crate) identity: Vec, } From 5eb44a157e91f25b09be6e922ce9c49164753ead Mon Sep 17 00:00:00 2001 From: Stefan Gehr Date: Wed, 28 Aug 2024 10:41:14 +0200 Subject: [PATCH 4/5] Use DirPath for output of rage-keygen as overwriting is not allowed --- rage/src/bin/rage-keygen/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rage/src/bin/rage-keygen/cli.rs b/rage/src/bin/rage-keygen/cli.rs index 66837c48..aaae2d21 100644 --- a/rage/src/bin/rage-keygen/cli.rs +++ b/rage/src/bin/rage-keygen/cli.rs @@ -36,7 +36,7 @@ pub(crate) struct AgeOptions { #[arg(short, long)] #[arg(value_name = fl!("output"))] #[arg(help = fl!("keygen-help-flag-output"))] - #[arg(value_hint = ValueHint::AnyPath)] + #[arg(value_hint = ValueHint::DirPath)] pub(crate) output: Option, #[arg(short = 'y')] From d483e0b06952b9ac65bb5f9856c8548eb9252d99 Mon Sep 17 00:00:00 2001 From: Stefan Gehr Date: Wed, 28 Aug 2024 10:41:42 +0200 Subject: [PATCH 5/5] cargo fmt --all --- rage/src/bin/rage-keygen/cli.rs | 5 ++++- rage/src/bin/rage-mount/cli.rs | 5 ++++- rage/src/bin/rage/cli.rs | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/rage/src/bin/rage-keygen/cli.rs b/rage/src/bin/rage-keygen/cli.rs index aaae2d21..f54eb317 100644 --- a/rage/src/bin/rage-keygen/cli.rs +++ b/rage/src/bin/rage-keygen/cli.rs @@ -1,4 +1,7 @@ -use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; +use clap::{ + builder::{Styles, ValueHint}, + ArgAction, Parser, +}; use crate::fl; diff --git a/rage/src/bin/rage-mount/cli.rs b/rage/src/bin/rage-mount/cli.rs index 9f82d568..66e4099a 100644 --- a/rage/src/bin/rage-mount/cli.rs +++ b/rage/src/bin/rage-mount/cli.rs @@ -1,4 +1,7 @@ -use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; +use clap::{ + builder::{Styles, ValueHint}, + ArgAction, Parser, +}; use crate::fl; diff --git a/rage/src/bin/rage/cli.rs b/rage/src/bin/rage/cli.rs index 25a7a4f4..1084ce5a 100644 --- a/rage/src/bin/rage/cli.rs +++ b/rage/src/bin/rage/cli.rs @@ -1,6 +1,9 @@ use std::path::Path; -use clap::{builder::{Styles, ValueHint}, ArgAction, Parser}; +use clap::{ + builder::{Styles, ValueHint}, + ArgAction, Parser, +}; use crate::fl;