mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 02:14:49 +00:00
Added init command to CLI
This commit is contained in:
1 parent
eb453976e2
commit
d525db7c01
1 file changed
+23
-1
+23
-1
@@ -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 `<command> --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.")
|
||||
|
||||
Reference in new issue
Block a user