auths_cli/commands/
approval.rs1use anyhow::Result;
4use clap::{Parser, Subcommand};
5
6use crate::commands::executable::ExecutableCommand;
7use crate::config::CliConfig;
8
9pub const EXIT_APPROVAL_REQUIRED: i32 = 75;
12
13#[derive(Parser, Debug)]
14#[command(
15 about = "Manage approval gates",
16 after_help = "Examples:
17 auths approval list # Show pending approval requests
18 auths approval grant --request <hash> --note 'Reviewed and approved'
19 # Grant approval for a request
20
21Exit Codes:
22 75 — Approval required (TEMPFAIL) — operation needs authorization
23
24Related:
25 auths policy — Manage capability policies
26 auths status — Check system status"
27)]
28pub struct ApprovalCommand {
29 #[command(subcommand)]
30 pub command: ApprovalSubcommand,
31}
32
33#[derive(Subcommand, Debug)]
34pub enum ApprovalSubcommand {
35 List(ApprovalListCommand),
37 Grant(ApprovalGrantCommand),
39}
40
41#[derive(Parser, Debug)]
42pub struct ApprovalListCommand {}
43
44#[derive(Parser, Debug)]
45pub struct ApprovalGrantCommand {
46 #[arg(long)]
48 pub request: String,
49 #[arg(long)]
51 pub note: Option<String>,
52}
53
54impl ExecutableCommand for ApprovalCommand {
55 fn execute(&self, _ctx: &CliConfig) -> Result<()> {
56 match &self.command {
57 ApprovalSubcommand::List(_cmd) => {
58 println!("No pending approval requests.");
59 Ok(())
60 }
61 ApprovalSubcommand::Grant(cmd) => {
62 println!(
63 "Approval grant for request {} — not yet wired to storage backend.",
64 cmd.request
65 );
66 Ok(())
67 }
68 }
69 }
70}