parent
68522f7bf1
commit
3bde91aeb4
@ -13,6 +13,7 @@ use clap::{
|
|||||||
use sequoia_directories::Home;
|
use sequoia_directories::Home;
|
||||||
|
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
pub mod inspect;
|
||||||
pub mod set;
|
pub mod set;
|
||||||
pub mod template;
|
pub mod template;
|
||||||
|
|
||||||
@ -138,5 +139,6 @@ pub struct Command {
|
|||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Subcommands {
|
pub enum Subcommands {
|
||||||
Get(get::Command),
|
Get(get::Command),
|
||||||
|
Inspect(inspect::Command),
|
||||||
Template(template::Command),
|
Template(template::Command),
|
||||||
}
|
}
|
||||||
|
34
src/cli/config/inspect.rs
Normal file
34
src/cli/config/inspect.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
//! Command-line parser for `sq config inspect`.
|
||||||
|
|
||||||
|
use clap::{
|
||||||
|
Parser,
|
||||||
|
Subcommand,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub mod policy;
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(
|
||||||
|
name = "inspect",
|
||||||
|
about = "Inspect effective configuration details",
|
||||||
|
long_about = "\
|
||||||
|
Inspect effective configuration details
|
||||||
|
|
||||||
|
This subcommand can be used to inspect various aspects of the \
|
||||||
|
effective configuration, such as various relevant paths, \
|
||||||
|
the cryptographic policy, the network configuration, etc.
|
||||||
|
",
|
||||||
|
subcommand_required = true,
|
||||||
|
arg_required_else_help = true,
|
||||||
|
disable_help_subcommand = true,
|
||||||
|
)]
|
||||||
|
pub struct Command {
|
||||||
|
#[clap(subcommand)]
|
||||||
|
pub subcommand: Subcommands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Subcommand)]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub enum Subcommands {
|
||||||
|
Policy(policy::Command),
|
||||||
|
}
|
35
src/cli/config/inspect/policy.rs
Normal file
35
src/cli/config/inspect/policy.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
//! Command-line parser for `sq config inspect policy`.
|
||||||
|
|
||||||
|
use clap::Args;
|
||||||
|
|
||||||
|
use crate::cli::examples::*;
|
||||||
|
|
||||||
|
#[derive(Debug, Args)]
|
||||||
|
#[clap(
|
||||||
|
name = "policy",
|
||||||
|
about = "Inspect the cryptographic policy",
|
||||||
|
long_about = "\
|
||||||
|
Inspect the cryptographic policy
|
||||||
|
|
||||||
|
Prints the cryptographic policy in the format that Sequoia uses to \
|
||||||
|
configure acceptance, rejection, and cutoff times for cryptographic \
|
||||||
|
algorithms.
|
||||||
|
|
||||||
|
See https://docs.rs/sequoia-policy-config/
|
||||||
|
",
|
||||||
|
after_help = EXAMPLES,
|
||||||
|
)]
|
||||||
|
pub struct Command {
|
||||||
|
}
|
||||||
|
|
||||||
|
const EXAMPLES: Actions = Actions {
|
||||||
|
actions: &[
|
||||||
|
Action::example()
|
||||||
|
.comment("Inspect the cryptographic policy.")
|
||||||
|
.command(&[
|
||||||
|
"sq", "config", "inspect", "policy",
|
||||||
|
])
|
||||||
|
.build(),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
test_examples!(sq_config_inspect_policy, EXAMPLES);
|
@ -23,12 +23,15 @@ use crate::{
|
|||||||
config::ConfigFile,
|
config::ConfigFile,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mod inspect;
|
||||||
|
|
||||||
pub fn dispatch(sq: Sq, cmd: config::Command)
|
pub fn dispatch(sq: Sq, cmd: config::Command)
|
||||||
-> Result<()>
|
-> Result<()>
|
||||||
{
|
{
|
||||||
match cmd.subcommand {
|
match cmd.subcommand {
|
||||||
config::Subcommands::Get(c) => get(sq, c),
|
config::Subcommands::Get(c) => get(sq, c),
|
||||||
config::Subcommands::Template(c) => template(sq, c),
|
config::Subcommands::Template(c) => template(sq, c),
|
||||||
|
config::Subcommands::Inspect(c) => inspect::dispatch(sq, c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
src/commands/config/inspect.rs
Normal file
30
src/commands/config/inspect.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//! Dispatches and implements `sq config inspect`.
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use sequoia_policy_config::{
|
||||||
|
ConfiguredStandardPolicy,
|
||||||
|
DumpDefault,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
Sq,
|
||||||
|
cli::config::inspect,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn dispatch(sq: Sq, cmd: inspect::Command)
|
||||||
|
-> Result<()>
|
||||||
|
{
|
||||||
|
match cmd.subcommand {
|
||||||
|
inspect::Subcommands::Policy(c) => policy(sq, c),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Implements `sq config inspect policy`.
|
||||||
|
fn policy(sq: Sq, _: inspect::policy::Command) -> Result<()> {
|
||||||
|
let p = ConfiguredStandardPolicy::from_policy(sq.policy.clone());
|
||||||
|
|
||||||
|
p.dump(&mut std::io::stdout(), DumpDefault::Explicit)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user