1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Command-line interface.
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use crate::config::{Config, OutputFormat};
/// APO — Engineering Evidence Platform.
#[derive(Debug, Parser)]
#[command(
name = "apo",
version,
about = "APO — Engineering Evidence Platform. Collect objective repository hygiene evidence.",
long_about = None
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
/// Top-level commands.
#[derive(Debug, Subcommand)]
pub enum Commands {
/// Analyze a local path or remote Git URI for hygiene evidence.
Analyze {
/// Local repository path or remote Git URI
/// (https://…, git@…, ssh://…, file://…).
#[arg(default_value = ".")]
target: String,
/// Output format: markdown, json, or both.
#[arg(long, default_value = "markdown")]
format: String,
/// Write report to this path (file) or directory.
#[arg(long)]
output: Option<PathBuf>,
/// Also write an LLM remediation prompt (`{repo}-repository-hygiene-prompt.md`)
/// that instructs a model to add missing artifacts and close gaps.
#[arg(long)]
llm_prompt: bool,
},
/// Analyze and emit only an LLM remediation prompt (stdout + file).
Prompt {
/// Local repository path or remote Git URI.
#[arg(default_value = ".")]
target: String,
/// Write prompt to this path (file) or directory.
#[arg(long)]
output: Option<PathBuf>,
/// Write the file only; do not print the prompt to stdout.
#[arg(long)]
quiet: bool,
},
}
impl Cli {
/// Convert CLI args into a [`Config`].
pub fn into_config(self) -> Result<Config, String> {
match self.command {
Commands::Analyze {
target,
format,
output,
llm_prompt,
} => Ok(Config {
target,
format: OutputFormat::parse(&format)?,
output,
llm_prompt,
prompt_only: false,
prompt_stdout: false,
..Config::default()
}),
Commands::Prompt {
target,
output,
quiet,
} => Ok(Config {
target,
format: OutputFormat::Markdown,
output,
llm_prompt: true,
prompt_only: true,
prompt_stdout: !quiet,
..Config::default()
}),
}
}
}