feat: --version flag

This commit is contained in:
meeg_leeto 2022-05-12 18:29:14 +01:00
parent 8c12dfc132
commit a5fd6bf61a
1 changed files with 10 additions and 0 deletions

View File

@ -971,14 +971,24 @@ async fn serve() {
#[derive(FromArgs, PartialEq, Debug)]
/// Start lonk.
struct Run {
/// print the version and quit
#[argh(switch)]
version: bool,
/// write a default configuration to stdout and quit
#[argh(switch)]
print_default_config: bool,
}
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
let run = argh::from_env::<Run>();
if run.version {
println!("lonk v{}", VERSION);
std::process::exit(0);
}
if run.print_default_config {
println!(
"{}",