@@ -28,15 +28,6 @@ pub enum SecretInput {
2828 Stdio ,
2929}
3030
31- #[ derive( Args , Clone , Debug , Default , PartialEq ) ]
32- pub struct SecretInputArg {
33- #[ clap( long, env) ]
34- auth_method : SecretInput ,
35-
36- #[ clap( long, env) ]
37- auth_dev : Option < PathBuf > ,
38- }
39-
4031impl From < SecretInput > for ArgPredicate {
4132 fn from ( val : SecretInput ) -> Self {
4233 let rep = match val {
@@ -58,20 +49,29 @@ impl From<SecretInput> for &str {
5849 }
5950}
6051
52+ #[ derive( Args , Clone , Debug , Default , PartialEq ) ]
53+ pub struct AuthInputArg {
54+ #[ clap( long = "auth-method" , env) ]
55+ method : SecretInput ,
56+
57+ #[ clap( long = "auth-device" , env) ]
58+ device : Option < PathBuf > ,
59+ }
60+
6161pub trait PasswordReader {
6262 fn read ( & mut self , prompt : & str ) -> Result < Zeroizing < String > > ;
6363}
6464
6565pub fn get_passwd_reader (
66- input : & SecretInputArg ,
66+ input : & AuthInputArg ,
6767) -> Result < Box < dyn PasswordReader > > {
68- Ok ( match input. auth_method {
68+ Ok ( match input. method {
6969 SecretInput :: Cdr => {
70- let cdr = CdReader :: new ( input. auth_dev . as_ref ( ) ) ;
70+ let cdr = CdReader :: new ( input. device . as_ref ( ) ) ;
7171 Box :: new ( CdrPasswordReader :: new ( cdr) )
7272 }
7373 SecretInput :: Iso => {
74- Box :: new ( IsoPasswordReader :: new ( input. auth_dev . as_ref ( ) ) ?)
74+ Box :: new ( IsoPasswordReader :: new ( input. device . as_ref ( ) ) ?)
7575 }
7676 SecretInput :: Stdio => Box :: new ( StdioPasswordReader { } ) ,
7777 } )
@@ -139,17 +139,26 @@ impl PasswordReader for CdrPasswordReader {
139139 }
140140}
141141
142+ #[ derive( Args , Clone , Debug , Default , PartialEq ) ]
143+ pub struct ShareInputArg {
144+ #[ clap( long = "share-method" , env) ]
145+ method : SecretInput ,
146+
147+ #[ clap( long = "share-device" , env) ]
148+ device : Option < PathBuf > ,
149+ }
150+
142151pub fn get_share_reader (
143- input : & SecretInputArg ,
152+ input : & ShareInputArg ,
144153 verifier : Verifier ,
145154) -> Result < Box < dyn Iterator < Item = Result < Zeroizing < Share > > > > > {
146- Ok ( match input. auth_method {
155+ Ok ( match input. method {
147156 SecretInput :: Cdr => {
148- let cdr = CdReader :: new ( input. auth_dev . as_ref ( ) ) ;
157+ let cdr = CdReader :: new ( input. device . as_ref ( ) ) ;
149158 Box :: new ( CdrShareReader :: new ( cdr, verifier) )
150159 }
151160 SecretInput :: Iso => {
152- Box :: new ( IsoShareReader :: new ( input. auth_dev . as_ref ( ) , verifier) ?)
161+ Box :: new ( IsoShareReader :: new ( input. device . as_ref ( ) , verifier) ?)
153162 }
154163 SecretInput :: Stdio => Box :: new ( StdioShareReader :: new ( verifier) ) ,
155164 } )
0 commit comments