Commit 9a149eea78
Unsigned
Layout: unified · split
src/commands/keys.rs +8 −3
| @@ -19,7 +19,7 @@ pub struct KeysCommand { | |||
| 19 | 19 | ||
| 20 | impl KeysCommand { | 20 | impl KeysCommand { |
| 21 | pub const DESCRIPTION: &'static str = "Import or export E2EE keys."; | 21 | pub const DESCRIPTION: &'static str = "Import or export E2EE keys."; |
| 22 | pub const COMPLETION: &'static str = "import|export %(filename)"; | 22 | pub const COMPLETION: &'static str = "import|export %(filename)"; |
| 23 | 23 | ||
| 24 | pub fn create(servers: &Servers) -> Result<Command, ()> { | 24 | pub fn create(servers: &Servers) -> Result<Command, ()> { |
| 25 | let settings = CommandSettings::new("keys") | 25 | let settings = CommandSettings::new("keys") |
| @@ -45,12 +45,17 @@ impl KeysCommand { | |||
| 45 | let passphrase = args | 45 | let passphrase = args |
| 46 | .args | 46 | .args |
| 47 | .get("passphrase") | 47 | .get("passphrase") |
| 48 | .map(|p| p.vals.iter().next().map(|p| p.clone().into_string().ok())) | 48 | .map(|p| p.vals.get(0).map(|p| p.clone().into_string().ok())) |
| 49 | .flatten() | 49 | .flatten() |
| 50 | .flatten() | 50 | .flatten() |
| 51 | .expect("No passphrase found"); | 51 | .expect("No passphrase found"); |
| 52 | 52 | ||
| 53 | let file = args.args.get("file").unwrap().vals.iter().next().unwrap(); | 53 | let file = args |
| 54 | .args | ||
| 55 | .get("file") | ||
| 56 | .map(|f| f.vals.get(0)) | ||
| 57 | .flatten() | ||
| 58 | .expect("No file found"); | ||
| 54 | let file = Weechat::expand_home(&file.to_string_lossy()); | 59 | let file = Weechat::expand_home(&file.to_string_lossy()); |
| 55 | let file = PathBuf::from(file); | 60 | let file = PathBuf::from(file); |
| 56 | (file, passphrase) | 61 | (file, passphrase) |