create djls-cli and migrate serving LSP to it (#20)

This commit is contained in:
Josh Thomas 2024-12-11 10:23:35 -06:00 committed by GitHub
parent 2cbc24b5f0
commit 4c10afb602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 46 additions and 4 deletions

View file

@ -0,0 +1,18 @@
[package]
name = "djls-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
djls-django = { workspace = true }
djls-server = { workspace = true }
anyhow = { workspace = true }
tokio = { workspace = true }
clap = { version = "4.5.23", features = ["derive"] }
tower-lsp = { version = "0.20.0", features = ["proposed"] }
[[bin]]
name = "djls"
path = "src/main.rs"

View file

@ -0,0 +1,24 @@
use clap::{Parser, Subcommand};
#[derive(Debug, Parser)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
/// Start the LSP server
Serve,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Commands::Serve => djls_server::serve().await?,
}
Ok(())
}

View file

@ -1,5 +1,5 @@
[package]
name = "djls"
name = "djls-server"
version = "0.1.0"
edition = "2021"

View file

@ -80,8 +80,7 @@ impl LanguageServer for TowerLspBackend {
}
}
#[tokio::main]
async fn main() -> Result<()> {
pub async fn serve() -> Result<()> {
let django = DjangoProject::setup()?;
let stdin = tokio::io::stdin();