Skip to content

Commit e427b56

Browse files
authored
Add --version flag to check version (#91)
1 parent bc3e069 commit e427b56

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

comfy_cli/cmdline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,19 @@ def entry(
111111
help="Enable tracking",
112112
),
113113
] = True,
114+
version: bool = typer.Option(
115+
False,
116+
"--version",
117+
"-v",
118+
help="Print version and exit",
119+
is_flag=True,
120+
callback=exclusivity_callback,
121+
),
114122
):
123+
if version:
124+
print(ConfigManager().get_cli_version())
125+
ctx.exit(0)
126+
115127
workspace_manager.setup_workspace_manager(workspace, here, recent, skip_prompt)
116128

117129
tracking.prompt_tracking_consent(skip_prompt, default_value=enable_telemetry)

comfy_cli/config_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import configparser
22
import os
33

4+
import tomlkit
5+
46
from comfy_cli.utils import singleton, get_os, is_running
57
from comfy_cli import constants, logging
68
from typing import Optional, Tuple
@@ -119,13 +121,13 @@ def remove_background(self):
119121
self.background = None
120122

121123
def get_cli_version(self):
122-
# Note: this approach should work for users installing the CLI via PyPi (e.g., pip install comfy-cli)
124+
# Note: this approach should work for users installing the CLI via
125+
# PyPi and Homebrew (e.g., pip install comfy-cli)
123126
try:
124127
return version("comfy-cli")
125128
except Exception as e:
126129
logging.debug(
127130
f"Error occurred while retrieving CLI version using importlib.metadata: {e}"
128131
)
129132

130-
# TODO: cover the users installing the CLI via homebrew
131133
return "0.0.0"

0 commit comments

Comments
 (0)