Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/socx/cli/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import rich_click as click

from socx.config import settings, CommandConverter
from socx.config import settings, CommandConverter, SymbolConverter
from socx.cli.types import AnyCallable
from socx.cli.plugin import PluginModel

Expand All @@ -23,6 +23,7 @@ def __init__(self, *args, **kwargs):
kwargs.setdefault("context_settings", settings.cli.context_settings)
super().__init__(*args, **kwargs)
self._converter = CommandConverter()
self._symbol_converter = SymbolConverter()
self._plugins = {p.name: PluginModel(**p) for p in settings.plugins} # pyright: ignore[reportOptionalIterable, reportGeneralTypeIssues]

@property
Expand All @@ -41,7 +42,15 @@ def get_command(
if plugin.script:
cmd = self._converter(plugin.script)
elif plugin.command:
cmd = self._converter(plugin.command)
# Try to use SymbolConverter first to preserve Group types
try:
cmd = self._symbol_converter(plugin.command)
# If it's not a Click command, use CommandConverter wrapper
if not isinstance(cmd, click.Command):
cmd = self._converter(plugin.command)
except Exception:
# Fall back to CommandConverter if SymbolConverter fails
cmd = self._converter(plugin.command)

if cmd is not None:
self.add_command(
Expand Down
8 changes: 7 additions & 1 deletion src/socx/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@
@option_panels()
@command_panels()
@click.pass_context
def cli(ctx: click.Context) -> int:
def cli(ctx: click.Context, interactive: bool = False) -> int:
"""System on chip verification and tooling infrastructure."""
ctx.ensure_object(DynaBox)

# If interactive mode is requested, start the REPL
if interactive:
from socx.cli.repl import start_repl
return start_repl(ctx)

if ctx.invoked_subcommand is None:
formatter = ctx.make_formatter()
ctx.command.format_help(ctx, formatter)
Expand Down
15 changes: 14 additions & 1 deletion src/socx/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@
)


interactive: Decorator[AnyCallable] = click.option(
"--interactive",
"-i",
"interactive",
help="Launch socx in interactive REPL mode.",
default=False,
is_flag=True,
is_eager=False,
show_default=True,
expose_value=True,
)


def join_decorators(*args: Any) -> Decorator[AnyCallable]:
"""Compose multiple option decorators into a single decorator."""

Expand All @@ -79,7 +92,7 @@ def _join_decorators(func):

def global_options() -> Callable[..., Decorator[AnyCallable]]:
"""Apply the standard set of global SoCX CLI options."""
return join_decorators(debug, configure, verbosity)
return join_decorators(interactive, debug, configure, verbosity)


def option_panels():
Expand Down
Loading