|
1 | 1 | from typing import List |
2 | 2 |
|
3 | 3 | import typer |
| 4 | +from rich.console import Console |
| 5 | +from rich.table import Table |
4 | 6 |
|
5 | 7 | import idom |
6 | 8 | from idom.client import manage as manage_client |
7 | 9 |
|
8 | 10 |
|
9 | 11 | main = typer.Typer() |
10 | | -show = typer.Typer() |
11 | | -main.add_typer(show, name="show", short_help="Display information about IDOM") |
| 12 | +console = Console() |
12 | 13 |
|
| 14 | +# --- Subcommands --- |
| 15 | +client = typer.Typer(name="client", short_help="Manage IDOM's built-in client") |
| 16 | +show = typer.Typer(name="show", short_help="Display information about IDOM") |
| 17 | +main.add_typer(client) |
| 18 | +main.add_typer(show) |
13 | 19 |
|
14 | | -@main.command() |
| 20 | + |
| 21 | +@client.command() |
15 | 22 | def install(packages: List[str]) -> None: |
16 | | - """Install a Javascript package from NPM""" |
17 | | - manage_client.build(packages) |
| 23 | + """Install a Javascript package from NPM into the client""" |
| 24 | + manage_client.build(packages, clean_build=False) |
18 | 25 | return None |
19 | 26 |
|
20 | 27 |
|
21 | | -@main.command() |
22 | | -def restore(clean_build: bool = True) -> None: |
23 | | - """Return to a fresh install of IDOM's client""" |
| 28 | +@client.command() |
| 29 | +def rebuild(clean: bool = False) -> None: |
| 30 | + """Rebuild the client (keeps currently installed packages by default)""" |
| 31 | + manage_client.build([], clean_build=clean) |
| 32 | + |
| 33 | + |
| 34 | +@client.command() |
| 35 | +def restore() -> None: |
| 36 | + """Return to a fresh install of Ithe client""" |
24 | 37 | manage_client.restore() |
25 | 38 | return None |
26 | 39 |
|
27 | 40 |
|
28 | 41 | @show.command() |
29 | | -def version() -> None: |
30 | | - """The version of IDOM""" |
31 | | - typer.echo(idom.__version__) |
| 42 | +def version(verbose: bool = False) -> None: |
| 43 | + """Show version information""" |
| 44 | + if not verbose: |
| 45 | + console.print(idom.__version__) |
| 46 | + else: |
| 47 | + table = Table() |
| 48 | + |
| 49 | + table.add_column("Package") |
| 50 | + table.add_column("Version") |
| 51 | + table.add_column("Language") |
| 52 | + |
| 53 | + table.add_row("idom", str(idom.__version__), "Python") |
| 54 | + |
| 55 | + for js_pkg, js_ver in manage_client.dependency_versions().items(): |
| 56 | + table.add_row(js_pkg, js_ver, "Javascript") |
| 57 | + |
| 58 | + console.print(table) |
0 commit comments