fix: revise the box command to not overflow
This commit is contained in:
parent
1a405e3f8b
commit
6f59fe5d1f
1 changed files with 12 additions and 6 deletions
|
|
@ -1,20 +1,26 @@
|
|||
use super::registry::get_registry;
|
||||
use boxutils::args::ArgParser;
|
||||
use boxutils::commands::Command;
|
||||
use std::env;
|
||||
|
||||
pub struct Boxcmd;
|
||||
|
||||
impl Command for Boxcmd {
|
||||
fn execute(&self) {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let parser = ArgParser::builder().parse_args("box");
|
||||
|
||||
let registry = get_registry();
|
||||
let command = &args.get(1);
|
||||
if let Some(cmd) = command {
|
||||
registry.execute(cmd);
|
||||
|
||||
for command in parser.get_normal_args() {
|
||||
if command == "box" {
|
||||
continue;
|
||||
}
|
||||
|
||||
registry.execute(&command);
|
||||
return;
|
||||
}
|
||||
|
||||
println!(
|
||||
"No command provided. Included commands:\n{}",
|
||||
"No valid command provided. Included commands:\n{}",
|
||||
registry.list().join(", ")
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue