-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
37 lines (30 loc) · 1015 Bytes
/
__init__.py
File metadata and controls
37 lines (30 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import click
from gitmojis.core import fetch_guide
def get_commands() -> list[click.Command]:
"""Return a list of `@click` commands defined in `gitmojis.cli.commands`."""
from gitmojis.cli import commands as commands_module
return [
command
for command in commands_module.__dict__.values()
if isinstance(command, click.Command)
]
@click.group(
name="gitmojis",
commands=get_commands(),
)
@click.option(
"--use-backup",
is_flag=True,
help="Use the backup to fetch data if the API request fails.",
)
@click.version_option(
package_name="python-gitmojis",
prog_name="gitmojis",
)
@click.pass_context
def gitmojis_cli(context: click.Context, use_backup: bool) -> None:
"""Command-line interface for managing the official Gitmoji guide."""
# Initialize the context object
context.ensure_object(dict)
# Pass the current state of the Gitmoji guide to the group context
context.obj["guide"] = fetch_guide(use_backup=use_backup)