mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 17:50:13 +00:00
feat(commands): add cs codegen to statically use params and flags in bot code, remove Any
This commit is contained in:
parent
0c012e98b5
commit
07e8a4851a
20 changed files with 297 additions and 417 deletions
|
|
@ -2,6 +2,11 @@
|
|||
name = "commands"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
default-run = "commands"
|
||||
|
||||
[[bin]]
|
||||
name = "write_cs_glue"
|
||||
path = "src/bin/write_cs_glue.rs"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#![feature(iter_intersperse)]
|
||||
|
||||
use command_parser::{token::Token, Tree};
|
||||
use commands::COMMAND_TREE;
|
||||
|
||||
fn main() {
|
||||
let cmd = std::env::args()
|
||||
.skip(1)
|
||||
|
|
@ -18,3 +21,21 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_tree(tree: &Tree, depth: usize) {
|
||||
println!();
|
||||
for (token, branch) in tree.branches() {
|
||||
for _ in 0..depth {
|
||||
print!(" ");
|
||||
}
|
||||
for _ in 0..depth {
|
||||
print!("-");
|
||||
}
|
||||
print!("> {token:?}");
|
||||
if matches!(token, Token::Empty) {
|
||||
println!(": {}", branch.command().unwrap().cb)
|
||||
} else {
|
||||
print_tree(branch, depth + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue