Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ members = ["crates/*"]
resolver = "2"

[workspace.dependencies]
djls = { path = "crates/djls" }
djls-ast = { path = "crates/djls-ast" }
djls-cli = { path = "crates/djls-cli" }
djls-django = { path = "crates/djls-django" }
djls-ipc = { path = "crates/djls-ipc" }
djls-python = { path = "crates/djls-python" }
Expand Down
57 changes: 0 additions & 57 deletions crates/djls-cli/src/main.rs

This file was deleted.

6 changes: 1 addition & 5 deletions crates/djls-cli/Cargo.toml → crates/djls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "djls-cli"
name = "djls"
version = "0.1.0"
edition = "2021"

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

clap = { version = "4.5", features = ["derive"] }
tower-lsp = { version = "0.20", features = ["proposed"] }

[[bin]]
name = "djls"
path = "src/main.rs"
13 changes: 13 additions & 0 deletions crates/djls/src/commands.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 54 additions & 0 deletions crates/djls/src/main.rs
Original file line number Diff line number Diff line change
@@ -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