Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please change error handling for gh config set ONE_ARG #9288

Open
jsoref opened this issue Jul 4, 2024 · 3 comments
Open

Please change error handling for gh config set ONE_ARG #9288

jsoref opened this issue Jul 4, 2024 · 3 comments
Labels
bug Something isn't working needs-triage needs to be reviewed

Comments

@jsoref
Copy link
Contributor

jsoref commented Jul 4, 2024

Describe the bug

gh version 2.51.0 (2024-06-13)
https://github.com/cli/cli/releases/tag/v2.51.0

I'm running a buggy script which uses gh config set ... and it's buggy. But it isn't showing the commands it runs, it only reports the output it receives from the programs it runs (and it's running lots of commands, so it isn't obvious that this is the command that it ran that triggered this output).

Steps to reproduce the behavior

  1. Type this gh config set /dev/null
  2. View the output accepts 2 arg(s), received 1
  3. Type this gh config set pager
  4. View the output accepts 2 arg(s), received 1

Expected vs actual behavior

  1. The output should report the name of the program that's being run (this is traditional) -- it's helpful when programs are run by complicated scripts (in my real world case, this is true).
  2. The output should be of the form gh config set: unrecognized config '/dev/null' or gh config: 'set pager' requires a value

Logs

@jsoref jsoref added the bug Something isn't working label Jul 4, 2024
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Jul 4, 2024
@williammartin
Copy link
Member

williammartin commented Jul 4, 2024

Heyo. That does sound annoying and I can understand why you would want this. Can you give some examples of programs you use that report the name as you say is traditional? Some example I see are:

➜  ~ rm --lol
rm: illegal option -- -
➜  ~ ls --lol
ls: unrecognized option `--lol'
usage: ls [-@ABCFGHILOPRSTUWabcdefghiklmnopqrstuvwxy1%,] [--color=when] [-D format] [file ...]

On the other hand, git and brew don't:

➜  ~ git --lol
unknown option: --lol
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--config-env=<name>=<envvar>] <command> [<args>]
➜  ~ brew --lol
Error: Unknown command: --lol

I wonder what the thought process is there.

@jsoref
Copy link
Contributor Author

jsoref commented Jul 4, 2024

% curl -T
curl: option -T: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information
% curl -A
curl: option -A: requires parameter
curl: try 'curl --help' or 'curl --manual' for more information

yes, rm / ls / bash are traditional...

% bash --unknown-flag
bash: --unknown-flag: invalid option
Usage:	bash [GNU long option] [option] ...
	bash [GNU long option] [option] script-file ...
...

even find is traditional in saying hello:

% find --unknown-option
find: illegal option -- -
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]

man:

% man --unknown-option
/usr/bin/man: illegal option -- -
Usage:
 man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect]
     [-m arch[:machine]] [-p [eprtv]] [mansect] page [...]
 man -f page [...] -- Emulates whatis(1)
 man -k page [...] -- Emulates apropos(1)

make:

% make --unknown-option
/Applications/Xcode.app/Contents/Developer/usr/bin/make: unrecognized option `--unknown-option'
Usage: make [options] [target] ...
..

gnu make:

% gmake --unknown-option
gmake: unrecognized option '--unknown-option'
Usage: gmake [options] [target] ...

cat:

% cat --unknown-option
cat: illegal option -- -
usage: cat [-belnstuv] [file ...]

@jsoref
Copy link
Contributor Author

jsoref commented Jul 5, 2024

fwiw, homebrew now identifies itself in errors: Homebrew/brew@8c4c731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage needs to be reviewed
Projects
None yet
Development

No branches or pull requests

3 participants