Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c6be94

Browse files
author
Gauvain Pocentek
committed
[cli] Restore the --help option behavior
Fixes#381
1 parentd35a31d commit7c6be94

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

‎gitlab/cli.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def cls_to_what(cls):
7777
returncamel_re.sub(r'\1-\2',cls.__name__).lower()
7878

7979

80-
def_get_base_parser():
81-
parser=argparse.ArgumentParser(
80+
def_get_base_parser(add_help=True):
81+
parser=argparse.ArgumentParser(add_help=add_help,
8282
description="GitLab API Command Line Interface")
8383
parser.add_argument("--version",help="Display the version.",
8484
action="store_true")
@@ -132,14 +132,20 @@ def main():
132132
print(gitlab.__version__)
133133
exit(0)
134134

135-
parser=_get_base_parser()
135+
parser=_get_base_parser(add_help=False)
136+
# This first parsing step is used to find the gitlab config to use, and
137+
# load the propermodule (v3 or v4) accordingly. At that point we don't have
138+
# any subparser setup
136139
(options,args)=parser.parse_known_args(sys.argv)
137140

138141
config=gitlab.config.GitlabConfigParser(options.gitlab,
139142
options.config_file)
140143
cli_module=importlib.import_module('gitlab.v%s.cli'%config.api_version)
144+
145+
# Now we build the entire set of subcommands and do the complete parsing
141146
parser=_get_parser(cli_module)
142147
args=parser.parse_args(sys.argv[1:])
148+
143149
config_files=args.config_file
144150
gitlab_id=args.gitlab
145151
verbose=args.verbose

‎gitlab/v4/cli.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def extend_parser(parser):
240240
arg_name=cli.cls_to_what(cls)
241241
object_group=subparsers.add_parser(arg_name)
242242

243-
object_subparsers=object_group.add_subparsers(
243+
object_subparsers=object_group.add_subparsers(title='action',
244244
dest='action',help="Action to execute.")
245245
_populate_sub_parser_by_class(cls,object_subparsers)
246246
object_subparsers.required=True

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp