feat(commands): make bin parse any commands passed to it

This commit is contained in:
dusk 2025-01-11 19:49:16 +09:00
parent 4f7e9c22a1
commit c43a855184
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -55,7 +55,7 @@ pub struct ParsedCommand {
pub flags: HashMap<String, Option<String>>,
}
fn parse_command(input: String) -> CommandResult {
pub fn parse_command(input: String) -> CommandResult {
let input: SmolStr = input.into();
let mut local_tree: TreeBranch = COMMAND_TREE.clone();

View file

@ -1,7 +1,18 @@
#![feature(iter_intersperse)]
use commands::commands as cmds;
fn main() {
for command in cmds::all() {
println!("{}", command);
let cmd = std::env::args()
.skip(1)
.intersperse(" ".to_string())
.collect::<String>();
if !cmd.is_empty() {
let parsed = commands::parse_command(cmd);
println!("{:#?}", parsed);
} else {
for command in cmds::all() {
println!("{}", command);
}
}
}