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

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ target
.k
OLD
tries
home
tmp
# enviroment to load on bin/build
.env

65
Cargo.lock generated
View File

@ -3854,7 +3854,38 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd"
[[package]]
name = "zterton"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"anyhow",
"app_auth",
"app_auth_handlers",
"app_env",
"app_errors",
"app_tools",
"async-std",
"async-trait",
"base64",
"clap",
"dotenv",
"envmnt 0.9.0",
"glob",
"json",
"kloud",
"once_cell",
"parking_lot",
"pretty_env_logger",
"serde",
"serde_derive",
"serde_json",
"serde_yaml",
"tempfile",
"thiserror",
"toml",
]
[[package]]
name = "zterton"
version = "0.1.2"
dependencies = [
"anyhow",
"app_auth",
@ -3874,6 +3905,7 @@ dependencies = [
"casbin",
"chrono",
"clds",
"dotenv",
"envmnt 0.9.0",
"futures-util",
"gql_playground",
@ -3904,34 +3936,3 @@ dependencies = [
"warp",
"zterton 0.1.1",
]
[[package]]
name = "zterton"
version = "0.1.1"
dependencies = [
"anyhow",
"app_auth",
"app_auth_handlers",
"app_env",
"app_errors",
"app_tools",
"async-std",
"async-trait",
"base64",
"clap",
"dotenv",
"envmnt 0.9.0",
"glob",
"json",
"kloud",
"once_cell",
"parking_lot",
"pretty_env_logger",
"serde",
"serde_derive",
"serde_json",
"serde_yaml",
"tempfile",
"thiserror",
"toml",
]

View File

@ -1,6 +1,6 @@
[package]
name = "zterton"
version = "0.1.0"
version = "0.1.2"
authors = ["JesusPerez <jpl@jesusperez.pro>"]
edition = "2018"
publish = false
@ -25,6 +25,7 @@ base64 = "0.13.0"
bytes = "1.0.1"
casbin = "2.0.7"
chrono = "0.4.19"
dotenv = "0.15.0"
envmnt = "0.9.0"
futures-util = "0.3.14"
http = "0.2.4"

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;