Skip to main content

agent_policy/
cli.rs

1//! Command-line interface definition.
2
3use clap::{Parser, Subcommand};
4
5/// Schema-first generator for coding-agent repo policies.
6#[derive(Parser)]
7#[command(
8    name = "agent-policy",
9    version,
10    about = "Schema-first generator for coding-agent repo policies.",
11    long_about = "Generates AGENTS.md, CLAUDE.md, and .cursor/rules from a canonical agent-policy.yaml.\n\nSee https://github.com/CameronBrooks11/agent-policy for documentation."
12)]
13pub struct Cli {
14    #[command(subcommand)]
15    pub command: Command,
16}
17
18/// Agent-policy subcommands.
19#[derive(Subcommand)]
20pub enum Command {
21    /// Write a starter agent-policy.yaml to the current directory.
22    Init {
23        /// Overwrite existing agent-policy.yaml if present.
24        #[arg(long)]
25        force: bool,
26    },
27
28    /// Generate all enabled output files from agent-policy.yaml.
29    Generate {
30        /// Path to agent-policy.yaml.
31        #[arg(long, short, default_value = "agent-policy.yaml")]
32        config: camino::Utf8PathBuf,
33
34        /// Specific targets to generate (overrides targets from the config file).
35        #[arg(long, short, value_delimiter = ',')]
36        targets: Option<Vec<String>>,
37    },
38
39    /// Check that committed generated files match the current policy.
40    ///
41    /// Exits non-zero if any generated file is stale or missing.
42    Check {
43        /// Path to agent-policy.yaml.
44        #[arg(long, short, default_value = "agent-policy.yaml")]
45        config: camino::Utf8PathBuf,
46
47        /// Specific targets to check (overrides targets from the config file).
48        #[arg(long, short, value_delimiter = ',')]
49        targets: Option<Vec<String>>,
50    },
51
52    /// Analyze agent-policy.yaml for semantic errors and warnings.
53    ///
54    /// Exits non-zero if validation errors (e.g., path conflicts) are found.
55    Lint {
56        /// Path to agent-policy.yaml.
57        #[arg(long, short, default_value = "agent-policy.yaml")]
58        config: camino::Utf8PathBuf,
59    },
60
61    /// List all supported output targets and their output paths.
62    #[command(name = "list-targets")]
63    ListTargets,
64
65    /// Install a git hook to automatically check agent-policy during commits.
66    #[command(name = "install-hooks")]
67    InstallHooks {
68        /// Install as a pre-push hook instead of pre-commit
69        #[arg(long)]
70        pre_push: bool,
71    },
72
73    /// Import existing AGENTS.md or CLAUDE.md to scaffold a new agent-policy.yaml.
74    Import,
75}