pub fn subcommand_execute(
    parent_command_name: &str,
    commands: Vec<Box<dyn Command>>,
    client: &mut ClientProxy,
    params: &[&str],
) {
    let mut commands_map = HashMap::new();
    for (i, cmd) in commands.iter().enumerate() {
        for alias in cmd.get_aliases() {
            if commands_map.insert(alias, i) != None {
                panic!("Duplicate alias {}", alias);
            }
        }
    }

    if params.is_empty() {
        print_subcommand_help(parent_command_name, &commands);
        return;
    }

    match commands_map.get(&params[0]) {
        Some(&idx) => commands[idx].execute(client, &params),
        _ => print_subcommand_help(parent_command_name, &commands),
    }
}
/// Execute sub command.
// TODO: Convert subcommands arrays to lazy statics
Execute sub command.
TODO: Convert subcommands arrays to lazy statics
Execute sub command . TODO : Convert subcommands arrays to lazy statics
pub fn subcommand_execute(
    parent_command_name: &str,
    commands: Vec<Box<dyn Command>>,
    client: &mut ClientProxy,
    params: &[&str],
) {
    let mut commands_map = HashMap::new();
    for (i, cmd) in commands.iter().enumerate() {
        for alias in cmd.get_aliases() {
            if commands_map.insert(alias, i) != None {
                panic!("Duplicate alias {}", alias);
            }
        }
    }
    if params.is_empty() {
        print_subcommand_help(parent_command_name, &commands);
        return;
    }
    match commands_map.get(&params[0]) {
        Some(&idx) => commands[idx].execute(client, &params),
        _ => print_subcommand_help(parent_command_name, &commands),
    }
}
pub fn subcommand_execute ( parent_command_name : & str , commands : Vec < Box < dyn Command > > , client : & mut ClientProxy , params : & [ & str ] , ) { let mut commands_map = HashMap :: new ( ) ; for ( i , cmd ) in commands . iter ( ) . enumerate ( ) { for alias in cmd . get_aliases ( ) { if commands_map . insert ( alias , i ) != None { panic ! ( " " alias ) ; } } } if params . is_empty ( ) { print_subcommand_help ( parent_command_name , & commands ) ; return ; } match commands_map . get ( & params [ 0 ] ) { Some ( & idx ) => commands [ idx ] . execute ( client , & params ) , _ => print_subcommand_help ( parent_command_name , & commands ) , } }
Execute sub command.
Execute sub command .
parent_command_name
&str
commands
Vec<Box<dyn Command>>
client
&mut ClientProxy
params
&[&str]
parent_command_name
&str
commands
Vec<Box<dyn Command>>
client
&mut ClientProxy
params
&[&str]