From c64f6a98363264474a194b10655ec62f1df8f9fb Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Thu, 14 Nov 2024 22:57:13 +0800 Subject: [PATCH] feat: v1.0.0, opt cli --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cli.rs | 2 +- src/main.rs | 10 +++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7da9040..e85f4a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -874,7 +874,7 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "local-mini-kms" -version = "0.3.8" +version = "1.0.0" dependencies = [ "aes-gcm-stream", "aes-kw", diff --git a/Cargo.toml b/Cargo.toml index 4fe62cd..8998eee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "local-mini-kms" -version = "0.3.8" +version = "1.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/cli.rs b/src/cli.rs index 2a8e698..53f850a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -138,7 +138,7 @@ async fn do_read(_arg_matches: &ArgMatches<'_>, sub_arg_matches: &ArgMatches<'_> return simple_error!("Require key"); }; let data = do_inner_request(sub_arg_matches, "read", &body).await?; - success!("Value: {}", serde_json::to_string_pretty(&data)?); + println!("{}", serde_json::to_string_pretty(&data)?); Ok(Some(0)) } diff --git a/src/main.rs b/src/main.rs index 03744d6..1f8bd56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,12 @@ impl DefaultCommandImpl { } fn main() { + if let Err(e) = inner_main() { + failure_and_exit!("Run local-mini-kms error: {}", e); + } +} + +fn harden_process() { let ignore_harden_process_error = std::env::var("IGNORE_HARDEN_PROCESS_ERROR") .map(|v| &v == "true").unwrap_or_else(|_| false); match secmem_proc::harden_process() { @@ -41,9 +47,6 @@ fn main() { } Ok(_) => success!("Harden local-mini-kms success"), } - if let Err(e) = inner_main() { - failure_and_exit!("Run local-mini-kms error: {}", e); - } } fn inner_main() -> CommandError { @@ -72,6 +75,7 @@ fn inner_main() -> CommandError { let matches = app.get_matches(); for command in &commands { if let Some(sub_cmd_matches) = matches.subcommand_matches(command.name()) { + if command.name() == "serve" { harden_process(); } return command.run(&matches, sub_cmd_matches); } }