#cli

xcli

xcli, a CLI implementation based on rustyline

6 releases (3 breaking)

0.5.2 Jan 25, 2021
0.5.1 Jan 14, 2021
0.3.0 Dec 30, 2020
0.2.0 Dec 23, 2020
0.1.0 Jul 9, 2020

#128 in Command-line interface

Download history 11/week @ 2021-02-21 8/week @ 2021-02-28 77/week @ 2021-03-07 19/week @ 2021-03-14 14/week @ 2021-03-21 18/week @ 2021-03-28 14/week @ 2021-04-04 15/week @ 2021-04-11 30/week @ 2021-04-18 3/week @ 2021-04-25 8/week @ 2021-05-02 2/week @ 2021-05-09 7/week @ 2021-05-16 2/week @ 2021-05-23 4/week @ 2021-05-30 11/week @ 2021-06-06

80 downloads per month
Used in 6 crates (3 directly)

MIT license

26KB
493 lines

xcli-rs

A CLI implementation in Rust that is based on Rustyline.

Supported Platforms

  • Unix
  • Windows
    • cmd.exe
    • Powershell
  • MacOS (not tested yet)

Note:

  • " quoted argument is not supported
  • No prompt is shown when running on non-tty device. Need a simple tweak on Rustyline...

Example

use xcli::*;

let mut app = App::new("xCLI")
    .version("v0.1")
    .author("kingwel.xie@139.com");

app.add_subcommand(Command::new("qwert")
    .about("controls testing features")
    .usage("qwert")
    .action(|_app, _actions| -> XcliResult {
        println!("qwert tested");
        Ok(CmdExeCode::Ok)
    }));

app.run();

crates.io

You can use this package in your project by adding the following to your Cargo.toml:

[dependencies]
xcli = "0.5.1"

ChangeLog

  • 2020.12.31, v0.5.0 API changes.

    • Allow a user data to be registered into xCli APP, and it can be retrieved later by user specified CLI commands
    • Refactor xCliError to take more error types.
    • add_subcommand_with_userdata() for attaching userdata to CLI sub commands
    • example updated to reflect the new APIs
  • 2021.1.11, v0.5.1

    • Command alias: command can have a short name
      tree            : tree
      mode            : mode [vi|emacs]
      log, l          : log [off|error|warn|info|debug|trace]
      help, h         : help [command]
      exit            : exit
      version, v      : version
      

Dependencies

~1.4–2.2MB
~46K SLoC