summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 91c086b..9e3b1e0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -118,12 +118,19 @@ enum Cmd {
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
- let cfg = match &cli.root {
- Some(r) => Config::load(r).unwrap_or_else(|_| Config {
- root: r.clone(),
+ // `init` is the only command that runs before a config exists. For everything
+ // else a missing config is the error it sounds like, not a reason to invent
+ // one: the old unconditional fallback turned a typo'd `--root` into a fresh
+ // empty server at the wrong path, whose commands then "succeeded" against a
+ // database with no subscriptions and no releases in it.
+ let root = cli.root.clone().unwrap_or_else(|| Config::default().root);
+ let cfg = if matches!(cli.cmd, Cmd::Init { .. }) {
+ Config::load(&root).unwrap_or_else(|_| Config {
+ root: root.clone(),
..Config::default()
- }),
- None => Config::load(&Config::default().root)?,
+ })
+ } else {
+ Config::load(&root)?
};
if let Cmd::Serve { bind } = &cli.cmd {
let mut cfg = cfg;