Skip to content

Commit d7171e0

Browse files
rename binary crate to djls
1 parent 340cd7a commit d7171e0

File tree

5 files changed

+69
-63
lines changed

5 files changed

+69
-63
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.dependencies]
6+
djls = { path = "crates/djls" }
67
djls-ast = { path = "crates/djls-ast" }
7-
djls-cli = { path = "crates/djls-cli" }
88
djls-django = { path = "crates/djls-django" }
99
djls-ipc = { path = "crates/djls-ipc" }
1010
djls-python = { path = "crates/djls-python" }

crates/djls-cli/src/main.rs

Lines changed: 0 additions & 57 deletions
This file was deleted.

crates/djls-cli/Cargo.toml renamed to crates/djls/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "djls-cli"
2+
name = "djls"
33
version = "0.1.0"
44
edition = "2021"
55

@@ -14,7 +14,3 @@ tokio = { workspace = true }
1414

1515
clap = { version = "4.5", features = ["derive"] }
1616
tower-lsp = { version = "0.20", features = ["proposed"] }
17-
18-
[[bin]]
19-
name = "djls"
20-
path = "src/main.rs"

crates/djls/src/commands.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use clap::{Parser, ValueEnum};
2+
3+
#[derive(Debug, Parser)]
4+
pub struct Serve {
5+
#[arg(short, long, default_value_t = ConnectionType::Stdio, value_enum)]
6+
connection_type: ConnectionType,
7+
}
8+
9+
#[derive(Clone, Debug, ValueEnum)]
10+
enum ConnectionType {
11+
Stdio,
12+
Tcp,
13+
}

crates/djls/src/main.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
mod commands;
2+
3+
use crate::commands::Serve;
4+
use anyhow::Result;
5+
use clap::{Parser, Subcommand};
6+
use djls_ipc::PythonProcess;
7+
use std::ffi::OsStr;
8+
use std::process::ExitCode;
9+
10+
#[derive(Parser)]
11+
#[command(name = "djls")]
12+
#[command(version, about, long_about = None)]
13+
pub struct Cli {
14+
#[command(subcommand)]
15+
command: Command,
16+
17+
#[command(flatten)]
18+
args: Args,
19+
}
20+
21+
#[derive(Debug, Subcommand)]
22+
enum Command {
23+
/// Start the LSP server
24+
Serve(Serve),
25+
}
26+
27+
#[derive(Parser)]
28+
pub struct Args {
29+
#[command(flatten)]
30+
global: GlobalArgs,
31+
}
32+
33+
#[derive(Parser, Debug, Clone)]
34+
struct GlobalArgs {
35+
/// Do not print any output.
36+
#[arg(global = true, long, short, conflicts_with = "verbose")]
37+
pub quiet: bool,
38+
39+
/// Use verbose output.
40+
#[arg(global = true, action = clap::ArgAction::Count, long, short, conflicts_with = "quiet")]
41+
pub verbose: u8,
42+
}
43+
44+
#[tokio::main]
45+
async fn main() -> Result<ExitCode> {
46+
let cli = Cli::parse();
47+
match cli.command {
48+
Command::Serve(_serve) => {
49+
let python = PythonProcess::new::<Vec<&OsStr>, &OsStr>("djls.agent", None, None)?;
50+
djls_server::serve(python).await?
51+
}
52+
}
53+
Ok(ExitCode::SUCCESS)
54+
}

0 commit comments

Comments
 (0)