feat: v1.0.0, opt cli

This commit is contained in:
2024-11-14 22:57:13 +08:00
parent f2ed407181
commit c64f6a9836
4 changed files with 10 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -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",

View File

@@ -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

View File

@@ -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))
}

View File

@@ -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);
}
}