Skip to content

Commit 1cef26f

Browse files
committed
feat(cli): rename 'ogx letsgo' to 'ogx go' with backward-compatible alias
Rename the top-level 'ogx letsgo' subcommand to 'ogx go' and the nested 'ogx stack letsgo' to 'ogx stack go'. Add a deprecated 'ogx letsgo' alias that emits a FutureWarning directing users to 'ogx go'. Update the persist-config distro directory name from 'letsgo-run' to 'go-run' for consistency. Add test coverage for the new deprecation warning. Signed-off-by: Matthew Farrellee <matt@cs.wisc.edu>
1 parent 79aa57b commit 1cef26f

4 files changed

Lines changed: 60 additions & 12 deletions

File tree

src/ogx/cli/letsgo.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the root directory of this source tree.
66

77
import argparse
8+
import warnings
89
from typing import Any
910

1011
from ogx.cli.stack.lets_go import add_letsgo_arguments, run_letsgo_cmd
@@ -14,12 +15,33 @@
1415
class LetsGo(Subcommand):
1516
"""Auto-detect providers, generate runtime config, and start the stack."""
1617

18+
def __init__(self, subparsers: Any) -> None:
19+
super().__init__()
20+
self.parser = subparsers.add_parser(
21+
"go",
22+
prog="ogx go",
23+
description="Auto-detect providers and start the stack",
24+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
25+
)
26+
self._add_arguments()
27+
self.parser.set_defaults(func=self._run_cmd)
28+
29+
def _add_arguments(self) -> None:
30+
add_letsgo_arguments(self.parser)
31+
32+
def _run_cmd(self, args: argparse.Namespace) -> None:
33+
run_letsgo_cmd(args, self.parser)
34+
35+
36+
class LetsGoDeprecated(Subcommand):
37+
"""Backward-compatible alias for 'ogx go' (deprecated)."""
38+
1739
def __init__(self, subparsers: Any) -> None:
1840
super().__init__()
1941
self.parser = subparsers.add_parser(
2042
"letsgo",
2143
prog="ogx letsgo",
22-
description="Auto-detect providers and start the stack",
44+
description="Auto-detect providers and start the stack (deprecated, use 'ogx go' instead)",
2345
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
2446
)
2547
self._add_arguments()
@@ -29,4 +51,9 @@ def _add_arguments(self) -> None:
2951
add_letsgo_arguments(self.parser)
3052

3153
def _run_cmd(self, args: argparse.Namespace) -> None:
54+
warnings.warn(
55+
"'ogx letsgo' is deprecated and will be removed in a future release. Use 'ogx go' instead.",
56+
FutureWarning,
57+
stacklevel=1,
58+
)
3259
run_letsgo_cmd(args, self.parser)

src/ogx/cli/ogx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Initialize logging early before any loggers get created
1313
setup_logging()
1414

15-
from .letsgo import LetsGo
15+
from .letsgo import LetsGo, LetsGoDeprecated
1616
from .run import Run
1717
from .stack import StackParser # type: ignore[attr-defined]
1818
from .stack.utils import print_subcommand_description
@@ -36,6 +36,7 @@ def __init__(self) -> None:
3636

3737
# Add sub-commands
3838
LetsGo.create(subparsers)
39+
LetsGoDeprecated.create(subparsers)
3940
Run.create(subparsers)
4041
StackParser.create(subparsers)
4142

src/ogx/cli/stack/lets_go.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ def run_letsgo_cmd(args: argparse.Namespace, parser: argparse.ArgumentParser) ->
132132
if not has_inference:
133133
parser.error("No inference providers detected. Nothing to run.")
134134

135-
distro_dir = DISTRIBS_BASE_DIR / "letsgo-run" if args.persist_config else Path(tempfile.mkdtemp())
135+
distro_dir = DISTRIBS_BASE_DIR / "go-run" if args.persist_config else Path(tempfile.mkdtemp())
136136
os.makedirs(distro_dir, exist_ok=True)
137137

138138
try:
139139
run_config = run_config_from_dynamic_config_spec(
140140
dynamic_config_spec=providers_spec,
141141
distro_dir=distro_dir,
142-
distro_name="letsgo-run",
142+
distro_name="go-run",
143143
)
144144
except ValueError as e:
145145
cprint(str(e), color="red", file=sys.stderr)
@@ -360,16 +360,16 @@ def _probe_endpoint(
360360

361361

362362
class StackLetsGo(Subcommand):
363-
"""Auto-detect providers, generate runtime config, and start the stack (deprecated, use 'ogx letsgo' instead)."""
363+
"""Auto-detect providers, generate runtime config, and start the stack (deprecated, use 'ogx go' instead)."""
364364

365365
def __init__(self, subparsers: Any) -> None:
366366
super().__init__()
367367
self.parser = subparsers.add_parser(
368-
"letsgo",
369-
prog="ogx stack letsgo",
368+
"go",
369+
prog="ogx stack go",
370370
description="""Auto-detect providers and start the stack.
371371
372-
NOTE: 'ogx stack letsgo' is deprecated. Use 'ogx letsgo' instead.""",
372+
NOTE: 'ogx stack go' is deprecated. Use 'ogx go' instead.""",
373373
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
374374
)
375375
self._add_arguments()
@@ -380,7 +380,7 @@ def _add_arguments(self) -> None:
380380

381381
def _run_stack_lets_go_cmd(self, args: argparse.Namespace) -> None:
382382
warnings.warn(
383-
"'ogx stack letsgo' is deprecated and will be removed in a future release. Use 'ogx letsgo' instead.",
383+
"'ogx stack go' is deprecated and will be removed in a future release. Use 'ogx go' instead.",
384384
FutureWarning,
385385
stacklevel=1,
386386
)

tests/unit/cli/test_stack_lets_go.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7-
"""Unit tests for `ogx letsgo` and `ogx stack letsgo` CLI commands."""
7+
"""Unit tests for `ogx go` and `ogx stack go` CLI commands."""
88

99
import argparse
1010
import warnings
@@ -13,7 +13,7 @@
1313
import httpx
1414
import pytest
1515

16-
from ogx.cli.letsgo import LetsGo
16+
from ogx.cli.letsgo import LetsGo, LetsGoDeprecated
1717
from ogx.cli.stack.lets_go import (
1818
_CLAUDE_CODE_ALIASES,
1919
_CLAUDE_CODE_PROVIDER_PRIORITY,
@@ -36,6 +36,12 @@ def top_level_letsgo() -> LetsGo:
3636
return LetsGo(subparsers)
3737

3838

39+
@pytest.fixture
40+
def top_level_letsgo_deprecated() -> LetsGoDeprecated:
41+
subparsers = argparse.ArgumentParser().add_subparsers()
42+
return LetsGoDeprecated(subparsers)
43+
44+
3945
class TestArguments:
4046
def test_defaults(self, lets_go: StackLetsGo):
4147
args = lets_go.parser.parse_args([])
@@ -452,7 +458,7 @@ def test_stack_letsgo_emits_deprecation_warning(self, lets_go: StackLetsGo):
452458
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
453459
assert len(future_warnings) == 1
454460
assert "deprecated" in str(future_warnings[0].message)
455-
assert "ogx letsgo" in str(future_warnings[0].message)
461+
assert "ogx go" in str(future_warnings[0].message)
456462

457463
def test_top_level_letsgo_no_deprecation_warning(self, top_level_letsgo: LetsGo):
458464
with (
@@ -466,6 +472,20 @@ def test_top_level_letsgo_no_deprecation_warning(self, top_level_letsgo: LetsGo)
466472
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
467473
assert len(future_warnings) == 0
468474

475+
def test_top_level_letsgo_deprecated_emits_deprecation_warning(self, top_level_letsgo_deprecated: LetsGoDeprecated):
476+
with (
477+
patch("ogx.cli.letsgo.run_letsgo_cmd"),
478+
warnings.catch_warnings(record=True) as w,
479+
):
480+
warnings.simplefilter("always")
481+
args = top_level_letsgo_deprecated.parser.parse_args([])
482+
top_level_letsgo_deprecated._run_cmd(args)
483+
484+
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
485+
assert len(future_warnings) == 1
486+
assert "deprecated" in str(future_warnings[0].message)
487+
assert "ogx go" in str(future_warnings[0].message)
488+
469489

470490
class TestClaudeCodeAliases:
471491
def test_anthropic_chosen_over_others(self):

0 commit comments

Comments
 (0)