Skip to content

help subcommand listed on help pages is refused by the usage-lib parser #1636

Closed

Description

@powerman

The help page of every command with subcommands lists
help Print this message or the help of the given subcommand(s),
but the usage-lib parser (usage bash, usage explain, …) refuses that word there:

#!/usr/bin/env -S usage bash
#USAGE name "x"
#USAGE bin "x"
#USAGE cmd "a" {
#USAGE   cmd "b"
#USAGE }
echo ran
$ ./x.sh --help
Usage: x [SUBCOMMAND]

Commands:
  a
  help  Print this message or the help of the given subcommand(s)

Flags:
  -h, --help  Print help
$ ./x.sh help
Error: unexpected word: help
$ ./x.sh help a
Error: unexpected word: help
$ ./x.sh a help
Error: unexpected word: help

On a leaf, where the page does not list it, the word is taken as a help request instead:
./x.sh a b help prints the page of x a b on stderr after Error: and exits 1.

Expected: what usage-argv does since #872 —
help [command...] answers with the long help of the named command wherever there are
subcommands, and to a leaf help is an ordinary word.

The condition in is_help_arg (lib/src/parse.rs:5544 on main) is the opposite of the one in
argv/src/lib.rs:2813: cmd.subcommands.is_empty() against !self.cmd.subcommands.is_empty().
The usage-lib rule predates #872 (#1123 moved it from the root to the current command)
and was not updated with it.

Reproduced with usage 7.3.0 and main (2117c3a).

AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.316.

Activity

  1. github-actions commented on Nov 16, 2026

    @github-actions
    Contributor

    Fixed in v7.4.0 by #1639.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions