summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-10 10:15:58 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-10 10:29:27 +0300
commit3295950f41342b8b9a312f203b111c7c277500b4 (patch)
treef9d54086c43a491b8df9bdcafbe61b70c39d2956
parent9243bc30891fc9db615560da8af83cf715664d9a (diff)
downloadobnam2-3295950f41342b8b9a312f203b111c7c277500b4.tar.gz
refactor: main function for clarity
-rw-r--r--src/bin/obnam.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/bin/obnam.rs b/src/bin/obnam.rs
index 4f4cd5b..cdb5179 100644
--- a/src/bin/obnam.rs
+++ b/src/bin/obnam.rs
@@ -27,19 +27,20 @@ fn main() -> anyhow::Result<()> {
debug!("{:?}", opt);
debug!("configuration: {:#?}", config);
- let result = if let Command::Init(init) = opt.cmd {
- init.run(config.config())
- } else {
- let config = load_config_with_passwords(&opt)?;
- match opt.cmd {
- Command::Init(_) => panic!("this cannot happen"),
- Command::Backup(x) => x.run(&config),
- Command::List(x) => x.run(&config),
- Command::ShowGeneration(x) => x.run(&config),
- Command::ListFiles(x) => x.run(&config),
- Command::Restore(x) => x.run(&config),
- Command::GetChunk(x) => x.run(&config),
- Command::Config(x) => x.run(&config),
+ let result = match opt.cmd {
+ Command::Init(x) => x.run(config.config()),
+ _ => {
+ let config = load_config_with_passwords(&opt)?;
+ match opt.cmd {
+ Command::Init(_) => panic!("this can't happen"),
+ Command::Backup(x) => x.run(&config),
+ Command::List(x) => x.run(&config),
+ Command::ShowGeneration(x) => x.run(&config),
+ Command::ListFiles(x) => x.run(&config),
+ Command::Restore(x) => x.run(&config),
+ Command::GetChunk(x) => x.run(&config),
+ Command::Config(x) => x.run(&config),
+ }
}
};