Add subcommand to list local certificates
- Add `husk locals list` to list all certificates which would be used by husk, but are not introduced by another certificate. These certificates are added 'locally'. - Refcator the code so that `local` -> `locals`.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::cli::cli_args::{LocalsCommand, LocalsSubcommand};
|
||||
use crate::common::crypto;
|
||||
use crate::config::HuskConfigContainer;
|
||||
use crate::types::husk_context::HuskContext;
|
||||
|
||||
pub mod add;
|
||||
pub mod remove;
|
||||
|
||||
pub async fn dispatch(cmd: LocalsCommand, config: HuskConfigContainer) -> Result<()> {
|
||||
match cmd.subcommand {
|
||||
LocalsSubcommand::Add(add_cmd) => {
|
||||
add::dispatch(add_cmd, &config).await?;
|
||||
},
|
||||
LocalsSubcommand::Remove(rm_cmd) => {
|
||||
remove::dispatch(rm_cmd, &config).await?;
|
||||
},
|
||||
LocalsSubcommand::List => {
|
||||
let context = HuskContext::new(&config.into())?;
|
||||
|
||||
println!("list locals");
|
||||
for local in crypto::get_locals(
|
||||
&context.cert_store,
|
||||
&context.policy,
|
||||
context.local_trust_root.fingerprint()) {
|
||||
|
||||
println!("{}", local);
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user