mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-12 05:07:40 +02:00
Added command line flags for help and version
Signed-off-by: zethra <benaagoldberg@gmail.com>
This commit is contained in:
27
src/main.rs
27
src/main.rs
@ -42,7 +42,18 @@ mod util;
|
||||
pub use config::CONFIG;
|
||||
pub use error::{Error, MapResult};
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "bitwarden_rs", about = "A Bitwarden API server written in Rust")]
|
||||
struct Opt {
|
||||
/// Prints the app version
|
||||
#[structopt(short, long)]
|
||||
version: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
parse_args();
|
||||
launch_info();
|
||||
|
||||
use log::LevelFilter as LF;
|
||||
@ -64,6 +75,18 @@ fn main() {
|
||||
launch_rocket(extra_debug);
|
||||
}
|
||||
|
||||
fn parse_args() {
|
||||
let opt = Opt::from_args();
|
||||
if opt.version {
|
||||
if let Some(version) = option_env!("GIT_VERSION") {
|
||||
println!("bitwarden_rs {}", version);
|
||||
} else {
|
||||
println!("bitwarden_rs (Version info from Git not present)");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
fn launch_info() {
|
||||
println!("/--------------------------------------------------------------------\\");
|
||||
println!("| Starting Bitwarden_RS |");
|
||||
@ -177,7 +200,9 @@ fn check_rsa_keys() {
|
||||
info!("JWT keys don't exist, checking if OpenSSL is available...");
|
||||
|
||||
Command::new("openssl").arg("version").status().unwrap_or_else(|_| {
|
||||
info!("Can't create keys because OpenSSL is not available, make sure it's installed and available on the PATH");
|
||||
info!(
|
||||
"Can't create keys because OpenSSL is not available, make sure it's installed and available on the PATH"
|
||||
);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user