Coverage for src\gibr\cli\group.py: 64%
14 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-20 09:51 +0300
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-20 09:51 +0300
1"""Custom Click group for Gibr CLI."""
3import click
6class GibrGroup(click.Group):
7 """Custom Click group."""
9 def parse_args(self, ctx, args):
10 """Parse args to handle 'git' alias routing and default command (create)."""
11 # If 'git' alias is present, handle it
12 if args and args[0] == "git":
13 args.pop(0)
15 # Move all flags (starting with '--') to the front
16 flags = [a for a in args if a.startswith("--")]
17 rest = [a for a in args if not a.startswith("--")]
18 args[:] = flags + rest
20 # Treat numeric as 'create' (gibr 123 -> gibr create 123)
21 for i, arg in enumerate(args):
22 if not arg.startswith("--"):
23 if arg.isdigit() and arg not in self.commands:
24 args.insert(i, "create")
25 break
27 return super().parse_args(ctx, args)