Skip to content

Commit

Permalink
Refine dev readme and add default invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
yoland68 committed Apr 16, 2024
1 parent 635a92e commit c50234a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
12 changes: 7 additions & 5 deletions DEV_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ This guide provides an overview of how to develop in this repository.

1. Clone the repo

2. Install requirements
2. Install the package to local

`pip install -r requirements.txt`
`pip install -e .`

3. Add commands or modify existing commands
3. Test script running

4. Test package:
`comfy --help`

4. Add more commands (follow the [Add New Command](#add-new-command) guide)

pip install .

## Add New Command

- Register it under `comfy/comfy.py`
- Register it under `comfy/cmdline.py`

If it's contains subcommand, create folder under comfy/command/[new_command] and
add the following boilerplate
Expand Down
10 changes: 8 additions & 2 deletions comfy/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typer
from typing_extensions import Annotated
from comfy.command.models import models
from rich import print


from comfy.command import custom_nodes
Expand All @@ -9,9 +10,14 @@
from comfy import constants
from comfy.env_checker import EnvChecker


app = typer.Typer()

@app.callback(invoke_without_command=True)
def no_command(ctx: typer.Context):
if ctx.invoked_subcommand is None:
print(ctx.get_help())
ctx.exit()

@app.command(help="Download and install ComfyUI")
def install(
url: str = constants.COMFY_GITHUB_URL,
Expand All @@ -32,4 +38,4 @@ def env():
env_checker.print()

app.add_typer(models.app, name="models", help="Manage models.")
app.add_typer(custom_nodes.app, name="custom_nodes", help="Manage custom nodes.")
app.add_typer(custom_nodes.app, name="nodes", help="Manage custom nodes.")
8 changes: 4 additions & 4 deletions comfy/command/custom_nodes/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# TODO(dr.lt.data): Add support for custom nodes managements
@app.command()
def add(name: str):
"""Add a new custom node"""
print(f"Adding a new custom node: {name}")
"""Add a new custom node"""
print(f"Adding a new custom node: {name}")


@app.command()
def remove(name: str):
"""Remove a custom node"""
print(f"Removing a custom node: {name}")
"""Remove a custom node"""
print(f"Removing a custom node: {name}")

0 comments on commit c50234a

Please sign in to comment.