mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-14 06:15:07 +00:00
rename binary crate to djls
(#32)
This commit is contained in:
parent
340cd7a1c0
commit
19b2566c8f
5 changed files with 69 additions and 63 deletions
13
crates/djls/src/commands.rs
Normal file
13
crates/djls/src/commands.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use clap::{Parser, ValueEnum};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Serve {
|
||||
#[arg(short, long, default_value_t = ConnectionType::Stdio, value_enum)]
|
||||
connection_type: ConnectionType,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, ValueEnum)]
|
||||
enum ConnectionType {
|
||||
Stdio,
|
||||
Tcp,
|
||||
}
|
54
crates/djls/src/main.rs
Normal file
54
crates/djls/src/main.rs
Normal file
|
@ -0,0 +1,54 @@
|
|||
mod commands;
|
||||
|
||||
use crate::commands::Serve;
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, Subcommand};
|
||||
use djls_ipc::PythonProcess;
|
||||
use std::ffi::OsStr;
|
||||
use std::process::ExitCode;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "djls")]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
|
||||
#[command(flatten)]
|
||||
args: Args,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum Command {
|
||||
/// Start the LSP server
|
||||
Serve(Serve),
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Args {
|
||||
#[command(flatten)]
|
||||
global: GlobalArgs,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
struct GlobalArgs {
|
||||
/// Do not print any output.
|
||||
#[arg(global = true, long, short, conflicts_with = "verbose")]
|
||||
pub quiet: bool,
|
||||
|
||||
/// Use verbose output.
|
||||
#[arg(global = true, action = clap::ArgAction::Count, long, short, conflicts_with = "quiet")]
|
||||
pub verbose: u8,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<ExitCode> {
|
||||
let cli = Cli::parse();
|
||||
match cli.command {
|
||||
Command::Serve(_serve) => {
|
||||
let python = PythonProcess::new::<Vec<&OsStr>, &OsStr>("djls.agent", None, None)?;
|
||||
djls_server::serve(python).await?
|
||||
}
|
||||
}
|
||||
Ok(ExitCode::SUCCESS)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue