RFR: 1275: An unknown sub-command gives a confusing error message
Guoxiong Li
gli at openjdk.java.net
Wed Dec 8 15:42:13 UTC 2021
On Wed, 8 Dec 2021 14:17:51 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> When using the unknown command, the client will output the unexpected message. For example:
>
>
> $ git-pr lis 123
>
> error: unexpected input: 123
> usage: git-pr [options] [<COMMAND>]
> -h, --help Show help
> --verbose Turn on verbose output
> --debug Turn on debugging output
> --version Print the version of this tool
>
>
> When the client can't identify the sub-command `git-pr lis`, it will execute the default command `git-pr help` and will pass `lis 123` as the argument to the `git-pr help` command. And the `git-pr help` can resolve only one argument, which is `lis` in this example, so it would output `error: unexpected input: 123`.
>
> This patch will output more information to the user:
>
>
> $ git-pr lis 123
>
> Can't find the sub-command 'lis', the default sub-command 'help' will be executed.
> The arguments [lis, 123] will be passed to the default sub-command.
>
> error: unexpected input: 123
> usage: git-pr [options] [<COMMAND>]
> -h, --help Show help
> --verbose Turn on verbose output
> --debug Turn on debugging output
> --version Print the version of this tool
>
>
> The added information can let the user know why the following output is shown.
>
> Thanks for taking the time to review.
>
> Best Regards,
> -- Guoxiong
If we only output `error: unknown sub-command: lis`, the following output is confused:
error: unexpected input: 123
usage: git-pr [options] [<COMMAND>] // <-- here should be `git-pr help [options] [<COMMAND>] `. See SKARA-1274
-h, --help Show help
--verbose Turn on verbose output
--debug Turn on debugging output
--version Print the version of this tool
The user would confuse why the client outputs the usage of the `git-pr help`. Because the user expects the following message.
error: unknown sub-command: lis
Available sub-commands are:
- apply
- approve
- cc
So I think it is necessary to let user know what is happening. As for `git webrev`, it will output the following message in my patch. Because the `git-webrev generate` will execute.
Can't find the sub-command 'lis', the default sub-command 'generate' will be executed.
The arguments [lis, 123] will be passed to the default sub-command.
Now I suggest the following information:
$ git-pr lis 123
error: unknown sub-command: lis
the default sub-command 'help' will be executed with the arguments [lis, 123].
error: unexpected input: 123
usage: git-pr [options] [<COMMAND>]
-h, --help Show help
--verbose Turn on verbose output
--debug Turn on debugging output
--version Print the version of this tool
$ git-webrev lis 123
error: unknown sub-command: lis
the default sub-command 'generate' will be executed with the arguments [lis, 123].
error: unexpected input: 123
usage: git webrev [options] [<FILE>]
// ignore
-------------
PR: https://git.openjdk.java.net/skara/pull/1257
More information about the skara-dev
mailing list