feat: scaffold CLI with fetch and render-md subcommands

This commit is contained in:
2026-04-08 22:46:33 +08:00
parent 1b5c8619d6
commit 0ce8786148
6 changed files with 270 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
use clap::Parser;
use gitea_pr_review::cli::{Cli, Commands, OutputFormat};
#[test]
fn parse_fetch_default_format() {
let cli = Cli::try_parse_from(["gitea-pr-review", "fetch", "12"]).unwrap();
match cli.command {
Commands::Fetch(args) => {
assert_eq!(args.pr_index, 12);
assert_eq!(args.format, OutputFormat::Markdown);
assert!(args.out.is_none());
}
_ => panic!("expected fetch"),
}
}
#[test]
fn parse_render_md_requires_input() {
let cli = Cli::try_parse_from([
"gitea-pr-review",
"render-md",
"--in",
"sample.json",
])
.unwrap();
match cli.command {
Commands::RenderMd(args) => {
assert_eq!(args.input.display().to_string(), "sample.json");
assert!(args.out.is_none());
}
_ => panic!("expected render-md"),
}
}