/// Create a new cli instance and return it
Create a new cli instance and return it
Create a new cli instance and return it
pub fn new<S: Into<String>>(n: S) -> Self {
        // note we set the name of roor command to "", len = 0
        let builtin_cmds =
            Command::new("")
                .about("Interactive CLI")
                .subcommand(Command::new("tree").about("prints the whole command tree").usage("tree").action(
                    |app: &App, _| -> XcliResult {
                        app.show_tree();
                        Ok(CmdExeCode::Ok)
                    },
                ))
                .subcommand(
                    Command::new("mode")
                        .about("manages the line editor mode, vi/emcas")
                        .usage("mode [vi|emacs]")
                        .action(cli_mode),
                )
                .subcommand(
                    Command::new_with_alias("log", "l")
                        .about("manages log level filter")
                        .usage("log [off|error|warn|info|debug|trace]")
                        .action(cli_log),
                )
                .subcommand(
                    Command::new_with_alias("help", "h")
                        .about("displays help information")
                        .usage("help [command]")
                        .action(cli_help),
                )
                .subcommand(
                    Command::new("exit")
                        .about("quits CLI and exits to shell")
                        .action(|_, _| -> XcliResult { Ok(CmdExeCode::Exit) }),
                )
                .subcommand(Command::new_with_alias("version", "v").about("shows version information").action(
                    |app, _| -> XcliResult {
                        println!("{}\n{}\n{}\n", app.get_name(), app.get_author(), app.get_version());
                        Ok(CmdExeCode::Ok)
                    },
                ));
        let rl = Rc::new(RefCell::new(Editor::<PrefixCompleter>::new()));
        App {
            name: n.into(),
            version: None,
            author: None,
            tree: builtin_cmds,
            rl,
            handlers: HashMap::default(),
        }
    }
pub fn new < S : Into < String > > ( n : S ) -> Self { // note we set the name of roor command to "", len = 0 let builtin_cmds = Command :: new ( " " ) . about ( " " ) . subcommand ( Command :: new ( " " ) . about ( " " ) . usage ( " " ) . action ( | app : & App , _ | -> XcliResult { app . show_tree ( ) ; Ok ( CmdExeCode :: Ok ) } , ) ) . subcommand ( Command :: new ( " " ) . about ( " " ) . usage ( " " ) . action ( cli_mode ) , ) . subcommand ( Command :: new_with_alias ( " " , " " ) . about ( " " ) . usage ( " " ) . action ( cli_log ) , ) . subcommand ( Command :: new_with_alias ( " " , " " ) . about ( " " ) . usage ( " " ) . action ( cli_help ) , ) . subcommand ( Command :: new ( " " ) . about ( " " ) . action ( | _ , _ | -> XcliResult { Ok ( CmdExeCode :: Exit ) } ) , ) . subcommand ( Command :: new_with_alias ( " " , " " ) . about ( " " ) . action ( | app , _ | -> XcliResult { println ! ( " \n \n \n " app get_name ( ) app get_author ( ) app get_version ( ) ) ; Ok ( CmdExeCode :: Ok ) } , ) ) ; let rl = Rc :: new ( RefCell :: new ( Editor :: < PrefixCompleter > :: new ( ) ) ) ; App { name : n . into ( ) , version : None , author : None , tree : builtin_cmds , rl , handlers : HashMap :: default ( ) , } }
Create a new cli instance and return it
Create a new cli instance and return it
n
S