pub fn _complete_cmd(node: &PrefixNode, line: &str, pos: usize) -> Vec<String> {
        debug!("cli to complete {} for node {}", line, node.name);
        let line = line[..pos].trim_start();
        let mut go_next = false;

        let mut new_line: Vec<String> = vec![];
        let mut offset: usize = 0;
        let mut next_node = None;

        //var lineCompleter PrefixCompleterInterface
        for child in &node.children {
            //debug!("try node {}", child.name);
            if line.len() >= child.name.len() {
                if line.starts_with(&child.name) {
                    if line.len() == child.name.len() {
                        // add a fack new_line " "
                        new_line.push(" ".to_string());
                    } else {
                        new_line.push(child.name.to_string());
                    }
                    offset = child.name.len();
                    next_node = Some(child);

                    // may go next level
                    go_next = true;
                }
            } else if child.name.starts_with(line) {
                new_line.push(child.name[line.len()..].to_string());
                offset = line.len();
                next_node = Some(child);
            }
        }

        // more than 1 candidates?
        if new_line.len() != 1 {
            debug!("offset={}, candidates={:?}", offset, new_line);
            return new_line;
        }

        if go_next {
            let line = line[offset..].trim_start();
            return PrefixCompleter::_complete_cmd(next_node.unwrap(), line, line.len());
        }

        debug!("offset={}, nl={:?}", offset, new_line);
        new_line
    }
/// Get all commands that match the line and pos
Get all commands that match the line and pos
Get all commands that match the line and pos
pub fn _complete_cmd(node: &PrefixNode, line: &str, pos: usize) -> Vec<String> {
        debug!("cli to complete {} for node {}", line, node.name);
        let line = line[..pos].trim_start();
        let mut go_next = false;
        let mut new_line: Vec<String> = vec![];
        let mut offset: usize = 0;
        let mut next_node = None;
        //var lineCompleter PrefixCompleterInterface
        for child in &node.children {
            //debug!("try node {}", child.name);
            if line.len() >= child.name.len() {
                if line.starts_with(&child.name) {
                    if line.len() == child.name.len() {
                        // add a fack new_line " "
                        new_line.push(" ".to_string());
                    } else {
                        new_line.push(child.name.to_string());
                    }
                    offset = child.name.len();
                    next_node = Some(child);
                    // may go next level
                    go_next = true;
                }
            } else if child.name.starts_with(line) {
                new_line.push(child.name[line.len()..].to_string());
                offset = line.len();
                next_node = Some(child);
            }
        }
        // more than 1 candidates?
        if new_line.len() != 1 {
            debug!("offset={}, candidates={:?}", offset, new_line);
            return new_line;
        }
        if go_next {
            let line = line[offset..].trim_start();
            return PrefixCompleter::_complete_cmd(next_node.unwrap(), line, line.len());
        }
        debug!("offset={}, nl={:?}", offset, new_line);
        new_line
    }
pub fn _complete_cmd ( node : & PrefixNode , line : & str , pos : usize ) -> Vec < String > { debug ! ( " " line node name ) ; let line = line [ .. pos ] . trim_start ( ) ; let mut go_next = false ; let mut new_line : Vec < String > = vec ! [ ] ; let mut offset : usize = 0 ; let mut next_node = None ; //var lineCompleter PrefixCompleterInterface for child in & node . children { //debug!("try node {}", child.name); if line . len ( ) >= child . name . len ( ) { if line . starts_with ( & child . name ) { if line . len ( ) == child . name . len ( ) { // add a fack new_line " " new_line . push ( " " . to_string ( ) ) ; } else { new_line . push ( child . name . to_string ( ) ) ; } offset = child . name . len ( ) ; next_node = Some ( child ) ; // may go next level go_next = true ; } } else if child . name . starts_with ( line ) { new_line . push ( child . name [ line . len ( ) .. ] . to_string ( ) ) ; offset = line . len ( ) ; next_node = Some ( child ) ; } } // more than 1 candidates? if new_line . len ( ) != 1 { debug ! ( " " offset new_line ) ; return new_line ; } if go_next { let line = line [ offset .. ] . trim_start ( ) ; return PrefixCompleter :: _complete_cmd ( next_node . unwrap ( ) , line , line . len ( ) ) ; } debug ! ( " " offset new_line ) ; new_line }
Get all commands that match the line and pos
Get all commands that match the line and pos
node
&PrefixNode
line
&str
pos
usize
node
&PrefixNode
line
&str
pos
usize