Skip to content

Commit

Permalink
Add help command to display help for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
yoland68 committed May 6, 2024
1 parent 7df0e80 commit 3a6c322
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def callback(_ctx: typer.Context, param: typer.CallbackParam, value: str):
exclusivity_callback = mutually_exclusive_group_options()


@app.command(help="Display help for commands")
def help(ctx: typer.Context):
print(ctx.find_root().get_help())
ctx.exit(0)


@app.callback(invoke_without_command=True)
def entry(
ctx: typer.Context,
Expand Down Expand Up @@ -225,32 +231,31 @@ def install(
print(f"ComfyUI is installed at: {comfy_path}")


@app.command(help="Stop background ComfyUI")
@tracking.track_command()
def update(target: str = typer.Argument("comfy", help="[all|comfy]")):
if target not in ["all", "comfy"]:
typer.echo(
f"Invalid target: {target}. Allowed targets are 'all', 'comfy'.",
err=True,
)
raise typer.Exit(code=1)

_env_checker = EnvChecker()
comfy_path = workspace_manager.workspace_path

if "all" == target:
custom_nodes.command.execute_cm_cli(["update", "all"])
else:
print(f"Updating ComfyUI in {comfy_path}...")
if comfy_path is None:
print("ComfyUI path is not found.")
raise typer.Exit(code=1)
os.chdir(comfy_path)
subprocess.run(["git", "pull"], check=True)
subprocess.run(
[sys.executable, "-m", "pip", "install", "-r", "requirements.txt"],
check=True,
)
# @app.command(help="Update ComfyUI custom nodes")
# @tracking.track_command()
# def update(target: str = typer.Argument("comfy", help="[all|comfy]")):
# if target not in ["all", "comfy"]:
# typer.echo(
# f"Invalid target: {target}. Allowed targets are 'all', 'comfy'.",
# err=True,
# )
# raise typer.Exit(code=1)

# comfy_path = workspace_manager.workspace_path

# if "all" == target:
# custom_nodes.command.execute_cm_cli(["update", "all"])
# else:
# print(f"Updating ComfyUI in {comfy_path}...")
# if comfy_path is None:
# print("ComfyUI path is not found.")
# raise typer.Exit(code=1)
# os.chdir(comfy_path)
# subprocess.run(["git", "pull"], check=True)
# subprocess.run(
# [sys.executable, "-m", "pip", "install", "-r", "requirements.txt"],
# check=True,
# )


# @app.command(help="Run workflow file")
Expand Down Expand Up @@ -396,7 +401,13 @@ def launch(

@app.command("set-default", help="Set default ComfyUI path")
@tracking.track_command()
def set_default(workspace_path: str):
def set_default(
# todo: support clear option
# clear: Annotated[bool, typer.Option(help="Clear existing default path")] = False,
workspace_path: Annotated[
str, typer.Argument(help="Path to ComfyUI workspace")
] = None
):
comfy_path = os.path.expanduser(workspace_path)

if not os.path.exists(comfy_path):
Expand Down

0 comments on commit 3a6c322

Please sign in to comment.