Skip to content

gitlab CLI --help not working as expected #381

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

Closed
jelaiw opened this issue Nov 27, 2017 · 2 comments
Closed

gitlab CLI --help not working as expected #381

jelaiw opened this issue Nov 27, 2017 · 2 comments
Milestone

Comments

@jelaiw
Copy link

jelaiw commented Nov 27, 2017

Just a quick report that gitlab CLI --help appears to not be working as expected.

In brief, gitlab CLI shows the help for "gitlab --help" even for calls for more specific help (e.g. "gitlab project --help" or "gitlab project list --help").

See below.

$ python3 --version
Python 3.6.3
$ python3 -m venv test-env
$ source test-env/bin/activate
(test-env) $ pip install --upgrade python-gitlab
Collecting python-gitlab
  Downloading python-gitlab-1.1.0.tar.gz (117kB)
    100% |████████████████████████████████| 122kB 1.9MB/s
Collecting requests>=1.0 (from python-gitlab)
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |████████████████████████████████| 92kB 1.9MB/s
Collecting six (from python-gitlab)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=1.0->python-gitlab)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.1MB/s
Collecting certifi>=2017.4.17 (from requests>=1.0->python-gitlab)
  Downloading certifi-2017.11.5-py2.py3-none-any.whl (330kB)
    100% |████████████████████████████████| 337kB 1.6MB/s
Collecting urllib3<1.23,>=1.21.1 (from requests>=1.0->python-gitlab)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |████████████████████████████████| 133kB 2.8MB/s
Collecting idna<2.7,>=2.5 (from requests>=1.0->python-gitlab)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 2.9MB/s
Installing collected packages: chardet, certifi, urllib3, idna, requests, six, python-gitlab
  Running setup.py install for python-gitlab ... done
Successfully installed certifi-2017.11.5 chardet-3.0.4 idna-2.6 python-gitlab-1.1.0 requests-2.18.4 six-1.11.0 urllib3-1.22
(test-env) $ gitlab project --help
usage: gitlab [-h] [--version] [-v] [-d] [-c CONFIG_FILE] [-g GITLAB]
              [-o {json,legacy,yaml}] [-f FIELDS]

GitLab API Command Line Interface

optional arguments:
  -h, --help            show this help message and exit
  --version             Display the version.
  -v, --verbose, --fancy
                        Verbose mode (legacy format only)
  -d, --debug           Debug mode (display HTTP requests
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        Configuration file to use. Can be used multiple times.
  -g GITLAB, --gitlab GITLAB
                        Which configuration section should be used. If not
                        defined, the default selection will be used.
  -o {json,legacy,yaml}, --output {json,legacy,yaml}
                        Output format (v4 only): json|legacy|yaml
  -f FIELDS, --fields FIELDS
                        Fields to display in the output (comma separated). Not
                        used with legacy output
(test-env) $ gitlab project list --help
usage: gitlab [-h] [--version] [-v] [-d] [-c CONFIG_FILE] [-g GITLAB]
              [-o {json,legacy,yaml}] [-f FIELDS]

GitLab API Command Line Interface

optional arguments:
  -h, --help            show this help message and exit
  --version             Display the version.
  -v, --verbose, --fancy
                        Verbose mode (legacy format only)
  -d, --debug           Debug mode (display HTTP requests
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        Configuration file to use. Can be used multiple times.
  -g GITLAB, --gitlab GITLAB
                        Which configuration section should be used. If not
                        defined, the default selection will be used.
  -o {json,legacy,yaml}, --output {json,legacy,yaml}
                        Output format (v4 only): json|legacy|yaml
  -f FIELDS, --fields FIELDS
                        Fields to display in the output (comma separated). Not
                        used with legacy output

I should say that I am a new python-gitlab user and I may be doing something dumb, so let me know if that is the case. I am just following the docs at http://python-gitlab.readthedocs.io/en/stable/cli.html.

A workaround right now is just to type "gitlab project foo" or something like that to trigger the CLI error path, which presents usage hints (which was what I was after in the first place).

@gpocentek gpocentek added this to the v1.3 milestone Jan 9, 2018
@gpocentek gpocentek modified the milestones: v1.3, v1.4 Feb 14, 2018
@jgeorgeson
Copy link

A workaround right now is just to type "gitlab project foo" or something like that to trigger the CLI error path, which presents usage hints (which was what I was after in the first place).

This doesn't always work though, such as trying to find the syntax for filtering for the user list command

(python-gitlab) 2/14/2018 12:58:34 PM jgeorgeson ~\Code
> gitlab user
usage: gitlab user [-h] {list,get,create,update,delete,block,unblock} ...
gitlab user: error: the following arguments are required: action
(python-gitlab) 2/14/2018 12:58:39 PM jgeorgeson ~\Code
> gitlab user list blah
usage: gitlab [-h] [--version] [-v] [-d] [-c CONFIG_FILE] [-g GITLAB]
              [-o {json,legacy,yaml}] [-f FIELDS]
              {< snipped full list of top-level commands >}
              ...
gitlab: error: unrecognized arguments: blah

I was able to find out by looking at the source here that any <command> list takes filters as --<key> <value>, and the list of filters for the UserManager.

@bittner
Copy link
Contributor

bittner commented Jan 29, 2019

Can we reopen this issue?

According to my investigation it should be sufficient to remove the if "--help" in sys.argv" block in gitlab.cli:main. Then adding --help at the end of a CLI command always shows the most specific help page automatically (ArgumentParser default behavior).

@xarx00 xarx00 mentioned this issue Mar 5, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants