Skip to content

Commit 4b58b5c

Browse files
committed
Add language list command to CLI
1 parent 731168d commit 4b58b5c

File tree

4 files changed

+129
-1
lines changed

4 files changed

+129
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/plotnik-cli/Cargo.toml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,62 @@ name = "plotnik-cli"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[features]
7+
default = [
8+
"bash",
9+
"c",
10+
"cpp",
11+
"csharp",
12+
"css",
13+
"elixir",
14+
"go",
15+
"haskell",
16+
"hcl",
17+
"html",
18+
"java",
19+
"javascript",
20+
"json",
21+
"kotlin",
22+
"lua",
23+
"nix",
24+
"php",
25+
"python",
26+
"ruby",
27+
"rust",
28+
"scala",
29+
"solidity",
30+
"swift",
31+
"typescript",
32+
"yaml",
33+
]
34+
bash = ["plotnik-langs/bash"]
35+
c = ["plotnik-langs/c"]
36+
cpp = ["plotnik-langs/cpp"]
37+
csharp = ["plotnik-langs/csharp"]
38+
css = ["plotnik-langs/css"]
39+
elixir = ["plotnik-langs/elixir"]
40+
go = ["plotnik-langs/go"]
41+
haskell = ["plotnik-langs/haskell"]
42+
hcl = ["plotnik-langs/hcl"]
43+
html = ["plotnik-langs/html"]
44+
java = ["plotnik-langs/java"]
45+
javascript = ["plotnik-langs/javascript"]
46+
json = ["plotnik-langs/json"]
47+
kotlin = ["plotnik-langs/kotlin"]
48+
lua = ["plotnik-langs/lua"]
49+
nix = ["plotnik-langs/nix"]
50+
php = ["plotnik-langs/php"]
51+
python = ["plotnik-langs/python"]
52+
ruby = ["plotnik-langs/ruby"]
53+
rust = ["plotnik-langs/rust"]
54+
scala = ["plotnik-langs/scala"]
55+
solidity = ["plotnik-langs/solidity"]
56+
swift = ["plotnik-langs/swift"]
57+
typescript = ["plotnik-langs/typescript"]
58+
yaml = ["plotnik-langs/yaml"]
59+
660
[dependencies]
761
clap = { version = "4.5.51", features = ["derive"] }
62+
plotnik-langs = { path = "../plotnik-langs", default-features = false }
863
plotnik-lib = { path = "../plotnik-lib" }
9-
rowan = "0.16"
64+
rowan = "0.16"

crates/plotnik-cli/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::{Args, Parser, Subcommand};
2+
use plotnik_langs::Lang;
23
use plotnik_lib::Query;
34
use std::fs;
45
use std::io::{self, Read};
@@ -61,6 +62,9 @@ EXAMPLES:
6162
/// Topic to display (e.g., "reference", "examples")
6263
topic: Option<String>,
6364
},
65+
66+
/// List supported languages
67+
Langs,
6468
}
6569

6670
#[derive(Args)]
@@ -133,6 +137,17 @@ fn main() {
133137
} => {
134138
run_debug(query, source, lang, output);
135139
}
140+
Command::Langs => {
141+
list_langs();
142+
}
143+
}
144+
}
145+
146+
fn list_langs() {
147+
let langs = Lang::all();
148+
println!("Supported languages ({}):", langs.len());
149+
for lang in langs {
150+
println!(" {}", lang.name());
136151
}
137152
}
138153

crates/plotnik-langs/src/lib.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,63 @@ impl Lang {
236236
}
237237
}
238238

239+
pub fn all() -> &'static [Self] {
240+
&[
241+
#[cfg(feature = "bash")]
242+
Self::Bash,
243+
#[cfg(feature = "c")]
244+
Self::C,
245+
#[cfg(feature = "cpp")]
246+
Self::Cpp,
247+
#[cfg(feature = "csharp")]
248+
Self::CSharp,
249+
#[cfg(feature = "css")]
250+
Self::Css,
251+
#[cfg(feature = "elixir")]
252+
Self::Elixir,
253+
#[cfg(feature = "go")]
254+
Self::Go,
255+
#[cfg(feature = "haskell")]
256+
Self::Haskell,
257+
#[cfg(feature = "hcl")]
258+
Self::Hcl,
259+
#[cfg(feature = "html")]
260+
Self::Html,
261+
#[cfg(feature = "java")]
262+
Self::Java,
263+
#[cfg(feature = "javascript")]
264+
Self::JavaScript,
265+
#[cfg(feature = "json")]
266+
Self::Json,
267+
#[cfg(feature = "kotlin")]
268+
Self::Kotlin,
269+
#[cfg(feature = "lua")]
270+
Self::Lua,
271+
#[cfg(feature = "nix")]
272+
Self::Nix,
273+
#[cfg(feature = "php")]
274+
Self::Php,
275+
#[cfg(feature = "python")]
276+
Self::Python,
277+
#[cfg(feature = "ruby")]
278+
Self::Ruby,
279+
#[cfg(feature = "rust")]
280+
Self::Rust,
281+
#[cfg(feature = "scala")]
282+
Self::Scala,
283+
#[cfg(feature = "solidity")]
284+
Self::Solidity,
285+
#[cfg(feature = "swift")]
286+
Self::Swift,
287+
#[cfg(feature = "typescript")]
288+
Self::TypeScript,
289+
#[cfg(feature = "typescript")]
290+
Self::Tsx,
291+
#[cfg(feature = "yaml")]
292+
Self::Yaml,
293+
]
294+
}
295+
239296
pub fn name(&self) -> &'static str {
240297
match self {
241298
#[cfg(feature = "bash")]

0 commit comments

Comments
 (0)