Skip to content

Commit ec39c8e

Browse files
committed
✨ print the defaut version if no argument
1 parent f8bf104 commit ec39c8e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/commands/default.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use thiserror::Error;
55

66
#[derive(clap::Parser, Debug)]
77
pub struct Default {
8-
link_version: version::Local,
8+
link_version: Option<version::Local>,
99
}
1010

1111
#[derive(Error, Debug)]
@@ -18,10 +18,19 @@ impl Command for Default {
1818
type Error = Error;
1919

2020
fn run(&self, config: &Config) -> Result<(), Error> {
21-
let cmd = super::Alias {
22-
alias: crate::version::Alias::default(),
23-
link_version: self.link_version,
24-
};
25-
cmd.run(config).map_err(Into::into)
21+
let alias = crate::version::Alias::default();
22+
if let Some(link_version) = self.link_version {
23+
let cmd = super::Alias {
24+
alias,
25+
link_version,
26+
};
27+
cmd.run(config).map_err(Into::into)
28+
} else {
29+
match alias.resolve(config.aliases_dir()) {
30+
Ok(version) => println!("{}", version),
31+
Err(_) => println!("none"),
32+
}
33+
Ok(())
34+
}
2635
}
2736
}

0 commit comments

Comments
 (0)