mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-29 11:01:13 +00:00
cli: fix crash by "jj <global_opts>" without subcommand
This commit is contained in:
parent
a5297c0082
commit
6d500ed66c
@ -4548,7 +4548,7 @@ fn cmd_git(
|
|||||||
|
|
||||||
pub fn default_app() -> clap::Command {
|
pub fn default_app() -> clap::Command {
|
||||||
let app: clap::Command = Commands::augment_subcommands(Args::command());
|
let app: clap::Command = Commands::augment_subcommands(Args::command());
|
||||||
app.arg_required_else_help(true)
|
app.arg_required_else_help(true).subcommand_required(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_command(
|
pub fn run_command(
|
||||||
|
@ -42,6 +42,21 @@ fn test_non_utf8_arg() {
|
|||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_subcommand() {
|
||||||
|
let test_env = TestEnvironment::default();
|
||||||
|
test_env.jj_cmd_cli_error(test_env.env_root(), &[]);
|
||||||
|
test_env.jj_cmd_cli_error(test_env.env_root(), &["-R."]);
|
||||||
|
|
||||||
|
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["--version"]);
|
||||||
|
insta::assert_snapshot!(stdout.replace(|c: char| c.is_ascii_digit(), "?"), @r###"
|
||||||
|
jj ?.?.?
|
||||||
|
"###);
|
||||||
|
|
||||||
|
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["--help"]);
|
||||||
|
insta::assert_snapshot!(stdout.lines().next().unwrap(), @"Jujutsu (An experimental VCS)");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_commit_working_copy() {
|
fn test_no_commit_working_copy() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user