From 6444f0e57b1209857ff7430794d931cb0c1e3d16 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Fri, 16 Apr 2021 00:08:44 -0600 Subject: [PATCH] clap-utils: Add explicit schemes for `ask` and `file` `SignerSource`s --- clap-utils/src/keypair.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/clap-utils/src/keypair.rs b/clap-utils/src/keypair.rs index 091f2ea3e..4c920eb52 100644 --- a/clap-utils/src/keypair.rs +++ b/clap-utils/src/keypair.rs @@ -150,6 +150,8 @@ pub(crate) fn parse_signer_source>(source: S) -> SignerSource { if let Some(scheme) = uri.scheme() { let scheme = scheme.as_str().to_ascii_lowercase(); match scheme.as_str() { + "ask" => SignerSource::Ask, + "file" => SignerSource::Filepath(uri.path().to_string()), "usb" => SignerSource::Usb(source.to_string()), _ => SignerSource::Filepath(source.to_string()), } @@ -478,5 +480,15 @@ mod tests { assert!(Pubkey::from_str(&junk).is_err()); assert!(matches!(parse_signer_source(&junk), SignerSource::Filepath(j) if j == junk)); + let ask = "ask:".to_string(); + assert!(matches!(parse_signer_source(&ask), SignerSource::Ask)); + let path = "/absolute/path".to_string(); + assert!( + matches!(parse_signer_source(&format!("file:{}", path)), SignerSource::Filepath(p) if p == path) + ); + let path = "relative/path".to_string(); + assert!( + matches!(parse_signer_source(&format!("file:{}", path)), SignerSource::Filepath(p) if p == path) + ); } }