Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Recognize implicit help requests to show help
Maximilian Roos6620ccad491d
diff --git a/src/main.rs b/src/main.rsindex 73bea93b9..c780f16f9 100644--- a/src/main.rs+++ b/src/main.rs@@ -74,7 +74,9 @@ fn maybe_handle_help_with_pager() -> bool {Ok(_) => false, // Normal args, not helpErr(err) => {match err.kind() {- ErrorKind::DisplayHelp => {+ ErrorKind::DisplayHelp+ | ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand+ | ErrorKind::MissingSubcommand => {// Re-resolve which subcommand's help user asked forlet target = help_resolver::resolve_target_command(&mut cmd, std::env::args());let mut help = target.render_long_help().to_string(); // StyledStr -> string (contains raw markdown)diff --git a/tests/integration_tests/help.rs b/tests/integration_tests/help.rsindex 04454cbfa..e4e88573b 100644--- a/tests/integration_tests/help.rs+++ b/tests/integration_tests/help.rs@@ -22,6 +22,12 @@ fn help_root() {snapshot_help("help_root", &["--help"]);}+#[test]+fn help_no_args() {+ // Running `wt` with no args should show help and exit 0+ snapshot_help("help_no_args", &[]);+}+#[test]fn help_config_shell() {snapshot_help("help_config_shell", &["config", "shell", "--help"]);diff --git a/tests/snapshots/integration__integration_tests__help__help_no_args.snap b/tests/snapshots/integration__integration_tests__help__help_no_args.snapnew file mode 100644index 000000000..df7c10978--- /dev/null+++ b/tests/snapshots/integration__integration_tests__help__help_no_args.snap@@ -0,0 +1,46 @@+---+source: tests/integration_tests/help.rs+info:+ program: wt+ args: []+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ GIT_EDITOR: ""+ WORKTRUNK_BIN: ""+ WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+wt - Git worktree management+Usage: wt [OPTIONS] <COMMAND>++Commands:+ config Manage configuration and shell integration+ step Workflow building blocks+ list List worktrees and optionally branches+ switch Switch to a worktree+ remove Remove worktree and branch+ merge Merge worktree into target branch++Options:+ -h, --help+ Print help (see a summary with '-h')++ -V, --version+ Print version++Global Options:+ -C <path>+ Working directory for this command++ --config <path>+ User config file path++ -v, --verbose+ Show commands and debug info++See [2mwt config --help[0m for configuration file locations and setup.