Skip to content
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

Added Dimonds and Ownership to cli and refactored subparser[Issue #20] #21

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions game7ctl/game7ctl/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import argparse
from typing import Callable

from .core import generate_cli as core_generate_cli
from .InventoryFacet import generate_cli as inventory_generate_cli
from .DiamondLoupeFacet import generate_cli as dloupe_generate_cli
from .DiamondCutFacet import generate_cli as dcut_generate_cli
from .OwnershipFacet import generate_cli as own_generate_cli
from .version import VERSION


def add_subparser(cmd_name: str, subparser: argparse.ArgumentParser, cli_gen: Callable):
subcommand = cli_gen()
subparser.add_parser(cmd_name, parents=[subcommand], add_help=False)


def generate_cli() -> argparse.ArgumentParser:
"""
Generates the argument parsers for the game7ctl command-line tool.
Expand All @@ -19,11 +28,15 @@ def generate_cli() -> argparse.ArgumentParser:

subparsers = parser.add_subparsers()

core_parser = core_generate_cli()
subparsers.add_parser("core", parents=[core_parser], add_help=False)

inventory_parser = inventory_generate_cli()
subparsers.add_parser("inventory", parents=[inventory_parser], add_help=False)
add_subparser(
"core",
subparsers,
core_generate_cli,
)
add_subparser("inventory", subparsers, inventory_generate_cli)
add_subparser("diamond-loupe", subparsers, dloupe_generate_cli)
add_subparser("diamond-cut", subparsers, dcut_generate_cli)
add_subparser("ownership", subparsers, own_generate_cli)

return parser

Expand Down
2 changes: 1 addition & 1 deletion game7ctl/game7ctl/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2