feat: scaffold CLI with fetch and render-md subcommands
This commit is contained in:
@@ -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"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user