Skip to content

Commit

Permalink
Added Dimonds and Ownership to cli and refactored subparser[Issue #20]
Browse files Browse the repository at this point in the history
Added better type hints.

black reformating

bumped the version number
  • Loading branch information
muddi900 committed Jan 23, 2023
1 parent 2c04437 commit d67b8ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
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

0 comments on commit d67b8ee

Please sign in to comment.