diff --git a/src/serena/cli.py b/src/serena/cli.py index 666815ee..480821c9 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -45,7 +45,7 @@ from solidlsp.util.subprocess_util import subprocess_kwargs log = logging.getLogger(__name__) -_MAX_CONTENT_WIDTH = 100 +_MAX_CONTENT_WIDTH = 200 _MODES_EXPLANATION = f"""\b\nBuilt-in mode names or paths to custom mode YAMLs with which to override the default modes defined in the global Serena configuration or the active project. @@ -155,6 +155,28 @@ class TopLevelCommands(AutoRegisteringGroup): def __init__(self) -> None: super().__init__(name="serena", help="Serena CLI commands. You can run ` --help` for more info on each command.") + @staticmethod + @click.command( + "init", + help="Initialize Serena by creating a global config file with the specified default language backend.", + context_settings={"max_content_width": _MAX_CONTENT_WIDTH}, + ) + @click.option( + "--language-backend", + "-b", + type=click.Choice([b.value for b in LanguageBackend]), + default=LanguageBackend.LSP.value, + show_default=True, + help="Default code intelligence backend (can be overridden in the project config).", + ) + def init(language_backend: Literal["LSP", "JetBrains"] = "LSP"): + serena_config = SerenaConfig.from_config_file() + serena_config.language_backend = LanguageBackend(language_backend) + serena_config.save() + click.echo( + f"Initialized Serena with default backend: {language_backend}.\nFind the global Serena config in:\n {serena_config.config_file_path}" + ) + @staticmethod @click.command("start-mcp-server", help="Starts the Serena MCP server.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH}) @click.option("--project", "project", type=PROJECT_TYPE, default=None, help="Path or name of project to activate at startup.")