Skip to content

Commit be60774

Browse files
committed
feat: add CLI scaffold with common LSP subcommands
1 parent d05cd6a commit be60774

File tree

3 files changed

+256
-65
lines changed

3 files changed

+256
-65
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ classifiers = [
1313
]
1414

1515
dependencies = [
16+
"typer>=0.12.0",
1617
"anyio>=4.10.0",
1718
"asyncer>=0.0.10",
1819
"attrs>=25.3.0",
@@ -23,6 +24,9 @@ dependencies = [
2324
"tenacity>=9.1.2",
2425
]
2526

27+
[project.scripts]
28+
lsp-client = "lsp_client.cli:app"
29+
2630
[dependency-groups]
2731
dev = [
2832
"pytest>=8.4.1",

src/lsp_client/cli.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
from __future__ import annotations
2+
3+
import typer
4+
5+
app = typer.Typer(help="LSP Client CLI")
6+
7+
8+
@app.command()
9+
def hover(
10+
path: str = typer.Argument(..., help="Path to the file"),
11+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
12+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
13+
):
14+
"""
15+
Request hover information at a given position.
16+
"""
17+
typer.echo(f"Hover at {path}:{line}:{character}")
18+
raise typer.Exit()
19+
20+
21+
@app.command()
22+
def definition(
23+
path: str = typer.Argument(..., help="Path to the file"),
24+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
25+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
26+
):
27+
"""
28+
Go to definition.
29+
"""
30+
typer.echo(f"Definition at {path}:{line}:{character}")
31+
raise typer.Exit()
32+
33+
34+
@app.command()
35+
def references(
36+
path: str = typer.Argument(..., help="Path to the file"),
37+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
38+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
39+
):
40+
"""
41+
Find references.
42+
"""
43+
typer.echo(f"References at {path}:{line}:{character}")
44+
raise typer.Exit()
45+
46+
47+
@app.command()
48+
def implementation(
49+
path: str = typer.Argument(..., help="Path to the file"),
50+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
51+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
52+
):
53+
"""
54+
Find implementations.
55+
"""
56+
typer.echo(f"Implementation at {path}:{line}:{character}")
57+
raise typer.Exit()
58+
59+
60+
@app.command()
61+
def type_definition(
62+
path: str = typer.Argument(..., help="Path to the file"),
63+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
64+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
65+
):
66+
"""
67+
Find type definition.
68+
"""
69+
typer.echo(f"Type definition at {path}:{line}:{character}")
70+
raise typer.Exit()
71+
72+
73+
@app.command()
74+
def symbols(
75+
path: str = typer.Argument(..., help="Path to the file"),
76+
):
77+
"""
78+
List document symbols.
79+
"""
80+
typer.echo(f"Symbols in {path}")
81+
raise typer.Exit()
82+
83+
84+
@app.command()
85+
def workspace_symbols(
86+
query: str = typer.Argument(..., help="Search query for workspace symbols"),
87+
):
88+
"""
89+
Search for workspace symbols.
90+
"""
91+
typer.echo(f"Workspace symbols for query: {query}")
92+
raise typer.Exit()
93+
94+
95+
@app.command()
96+
def rename(
97+
path: str = typer.Argument(..., help="Path to the file"),
98+
line: int = typer.Argument(..., help="Line number (0-indexed)"),
99+
character: int = typer.Argument(..., help="Character position (0-indexed)"),
100+
new_name: str = typer.Argument(..., help="The new name for the symbol"),
101+
):
102+
"""
103+
Rename a symbol.
104+
"""
105+
typer.echo(f"Rename at {path}:{line}:{character} to {new_name}")
106+
raise typer.Exit()
107+
108+
109+
if __name__ == "__main__":
110+
app()

0 commit comments

Comments
 (0)