| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b47c26 commit 14df327
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,11 +200,15 @@ def _populate_sub_parser_by_class( | |||
| 200 | 200 | mgr_cls_name = f"{cls.__name__}Manager" | |
| 201 | 201 | mgr_cls = getattr(gitlab.v4.objects, mgr_cls_name) | |
| 202 | 202 | ||
| 203 | - for action_name in ["list", "get", "create", "update", "delete"]: | ||
| 203 | + ACTIONS = ("list", "get", "create", "update", "delete") | ||
| 204 | + action_parsers = set() | ||
| 205 | + | ||
| 206 | + for action_name in ACTIONS: | ||
| 204 | 207 | if not hasattr(mgr_cls, action_name): | |
| 205 | 208 | continue | |
| 206 | 209 | ||
| 207 | 210 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 211 | + action_parsers.add(action_name) | ||
| 208 | 212 | sub_parser_action.add_argument("--sudo", required=False) | |
| 209 | 213 | if mgr_cls._from_parent_attrs: | |
| 210 | 214 | for x in mgr_cls._from_parent_attrs: | |
@@ -268,6 +272,9 @@ def _populate_sub_parser_by_class( | |||
| 268 | 272 | if cls.__name__ in cli.custom_actions: | |
| 269 | 273 | name = cls.__name__ | |
| 270 | 274 | for action_name in cli.custom_actions[name]: | |
| 275 | + if action_name in action_parsers: | ||
| 276 | + continue | ||
| 277 | + | ||
| 271 | 278 | sub_parser_action = sub_parser.add_parser(action_name) | |
| 272 | 279 | # Get the attributes for URL/path construction | |
| 273 | 280 | if mgr_cls._from_parent_attrs: | |
@@ -326,16 +333,15 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: | |||
| 326 | 333 | subparsers.required = True | |
| 327 | 334 | ||
| 328 | 335 | # populate argparse for all Gitlab Object | |
| 329 | - classes = [] | ||
| 336 | + classes = set() | ||
| 330 | 337 | for cls in gitlab.v4.objects.__dict__.values(): | |
| 331 | 338 | if not isinstance(cls, type): | |
| 332 | 339 | continue | |
| 333 | 340 | if issubclass(cls, gitlab.base.RESTManager): | |
| 334 | 341 | if cls._obj_cls is not None: | |
| 335 | - classes.append(cls._obj_cls) | ||
| 336 | - classes.sort(key=operator.attrgetter("__name__")) | ||
| 342 | + classes.add(cls._obj_cls) | ||
| 337 | 343 | ||
| 338 | - for cls in classes: | ||
| 344 | + for cls in sorted(classes, key=operator.attrgetter("__name__")): | ||
| 339 | 345 | arg_name = cli.cls_to_what(cls) | |
| 340 | 346 | object_group = subparsers.add_parser(arg_name) | |
| 341 | 347 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments