chore: add version flag

This commit is contained in:
Jesús Pérez Lorenzo 2021-08-31 23:01:15 +01:00
parent 1588e7bec0
commit 099fe105a3
4 changed files with 56 additions and 40 deletions

View file

@ -39,9 +39,10 @@ use reqenv::ReqEnv;
// extern crate kloud_entries_macro_derive;
static WEBSERVER: AtomicUsize = AtomicUsize::new(0);
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
// const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
const AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS");
const PKG_VERSION: &'static str = env!("CARGO_PKG_VERSION");
// const PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
const PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
const PKG_AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS");
pub mod defs;
pub mod graphql;
@ -88,8 +89,8 @@ async fn up_web_server() -> Result<()> {
let mut app_env = AppEnv::default();
app_env.info = AppInfo::new(
"Zterton",
format!("version: {}",VERSION),
format!("Authors: {}",AUTHORS),
format!("version: {}",PKG_VERSION),
format!("Authors: {}",PKG_AUTHORS),
).await;
println!("Web services: init {} ___________ ", chrono::Utc::now().timestamp());
zterton::init_app(&mut app_env,"").await?;
@ -285,8 +286,16 @@ pub async fn run_check_clouds() {
pub fn main() -> Result<()> {
let args: Vec<String> = std::env::args().collect();
// println!("I got {:?} arguments: {:?}.", args.len() - 1, &args[1..]);
if args.len() > 1 && ( args[1] == "-h" || args[1] == "--help") {
println!("{} USAGE: -c config-toml -e env.file",&args[0]);
if args.len() > 1 {
match args[1].as_str() {
"-h" | "--help" =>
println!("{} USAGE: -c config-toml -e env.file",PKG_NAME),
"-v" | "--version" => {
println!("{} version: {}",PKG_NAME,PKG_VERSION);
return Ok(());
},
_ => println!("{}",PKG_NAME),
}
}
let mut arg_cfg_path = String::from("");
let mut arg_env_path = String::from("");
@ -297,6 +306,10 @@ pub fn main() -> Result<()> {
arg_env_path=args[idx+1].to_owned();
}
});
if !arg_env_path.is_empty() {
let env_path = std::path::Path::new(&arg_env_path);
dotenv::from_path(env_path)?;
}
// assert!(output.is_ok());
let loop_duration: u64;
let run_cache: bool;