refactor(cli): centralize Typer app creation and command registration

This commit is contained in:
2026-03-06 16:07:01 +08:00
parent 7dbd704d6b
commit 4a6918ce56
7 changed files with 20 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
from .train import train
from .app import app
from .benchmark import benchmark
from .visualize import visualize
from .generate import generate
from .train import train
from .visualize import visualize
__all__ = ["train", "benchmark", "visualize", "generate"]
__all__ = ["app", "train", "benchmark", "visualize", "generate"]

7
mini-nav/commands/app.py Normal file
View File

@@ -0,0 +1,7 @@
import typer
app = typer.Typer(
name="mini-nav",
help="Mini-Nav: A vision-language navigation system",
add_completion=False,
)

View File

@@ -1,8 +1,10 @@
from typing import cast
import typer
from commands import app
@app.command()
def benchmark(
ctx: typer.Context,
model_path: str = typer.Option(

View File

@@ -1,6 +1,8 @@
import typer
from commands import app
@app.command()
def generate(ctx: typer.Context):
from configs import cfg_manager
from data_loading.synthesizer import ImageSynthesizer

View File

@@ -1,6 +1,8 @@
import typer
from commands import app
@app.command()
def train(
ctx: typer.Context,
epoch_size: int = typer.Option(10, "--epoch", "-e", help="Number of epochs"),

View File

@@ -1,6 +1,8 @@
import typer
from commands import app
@app.command()
def visualize(
ctx: typer.Context,
host: str = typer.Option("127.0.0.1", "--host", help="Server host"),

View File

@@ -1,16 +1,4 @@
import typer
from commands import benchmark, generate, train, visualize
app = typer.Typer(
name="mini-nav",
help="Mini-Nav: A vision-language navigation system",
add_completion=False,
)
app.command(name="train")(train)
app.command(name="benchmark")(benchmark)
app.command(name="visualize")(visualize)
app.command(name="generate")(generate)
from commands import app
if __name__ == "__main__":
app()