summaryrefslogtreecommitdiff
path: root/src/cmd/init.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-10 10:10:20 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-10 10:29:27 +0300
commit9243bc30891fc9db615560da8af83cf715664d9a (patch)
treee3ab9a5affb151993fc9caf895b5c924ffc552d4 /src/cmd/init.rs
parent958839c264b3ef36ef1bc74a4794fc383cc39292 (diff)
downloadobnam2-9243bc30891fc9db615560da8af83cf715664d9a.tar.gz
refactor: have ClientConfigWithoutPasswords know its filename
This allows Init::run to not need to be given it as an argument.
Diffstat (limited to 'src/cmd/init.rs')
-rw-r--r--src/cmd/init.rs9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/cmd/init.rs b/src/cmd/init.rs
index 462174e..cb61fba 100644
--- a/src/cmd/init.rs
+++ b/src/cmd/init.rs
@@ -1,7 +1,6 @@
use crate::config::ClientConfigWithoutPasswords;
use crate::error::ObnamError;
use crate::passwords::{passwords_filename, Passwords};
-use std::path::Path;
use structopt::StructOpt;
const PROMPT: &str = "Obnam passphrase: ";
@@ -13,11 +12,7 @@ pub struct Init {
}
impl Init {
- pub fn run(
- &self,
- config: &ClientConfigWithoutPasswords,
- config_filename: &Path,
- ) -> Result<(), ObnamError> {
+ pub fn run(&self, config: &ClientConfigWithoutPasswords) -> Result<(), ObnamError> {
if !config.encrypt {
panic!("no encryption specified");
}
@@ -28,7 +23,7 @@ impl Init {
};
let passwords = Passwords::new(&passphrase);
- let filename = passwords_filename(config_filename);
+ let filename = passwords_filename(&config.filename);
passwords
.save(&filename)
.map_err(|err| ObnamError::PasswordSave(filename, err))?;