8 breaking releases

0.12.0 Apr 10, 2024
0.10.0 Jan 14, 2024
0.9.4 Sep 16, 2023
0.6.1 Jul 24, 2023

#605 in Command line utilities

Download history 76/week @ 2024-02-24 1/week @ 2024-03-02 9/week @ 2024-03-09 1/week @ 2024-03-16 20/week @ 2024-03-30 246/week @ 2024-04-06 409/week @ 2024-04-13 1/week @ 2024-04-20 4/week @ 2024-04-27 1/week @ 2024-05-04

446 downloads per month
Used in dedoc

MIT license



A framework for command line applications, including a command line argument parser.

Complete overview can be found in the documentation for each module.

Modules can be disabled/enabled via features:

default = ["flags", "colors", "escapes"]


//! Command line argument parsing.

use std::env::args;

use toiletcli::flags;
use toiletcli::flags::{FlagType, parse_flags, parse_flags_until_subcommand};

let mut args = args();

// Most often, path to the program will be the first argument.
// This will prevent the function from parsing, as path to the program does not start with '-'.
let program_name = args.next().unwrap();

let mut v_flag;

let mut main_flags = flags![
    v_flag: BoolFlag, ["-v", "--long-v"]

let subcommand = parse_flags_until_subcommand(&mut args, &mut main_flags).unwrap();

let mut d_flag;

let mut sub_flags = flags![
    d_flag: BoolFlag, ["-d"]

let subcommand_args = parse_flags(&mut args, &mut sub_flags);
//! Convenient ANSI terminal colors and styles.

use toiletcli::colors::{Color, Style, UnderlineStyle, StyleBuilder};

println!("{}{}This is red text on blue background!{}",
         Color::Red, Color::Blue.bg(), Style::Reset);

let weird_style = StyleBuilder::new()
    .underline_color(Color::RGB(0, 255, 0))

println!("{}RGB purple on black background with RGB curly green underline!{}",
        weird_style, Style::Reset);
//! Most common escapes to manipulate terminals.

use toiletcli::escapes::{Cursor, System};

println!("This is a 'word' that will be replaced!{}bird", Cursor::Position(12));
// This is a 'bird' that will be replaced!

println!("This is a '{}dog' that will be replaced too!{}cat", Cursor::Save, Cursor::Restore);
// This is a 'cat' that will be replaced too!

print!("{}", System::SetTitle("hello"));
// Look at the title :3
//! Common functions.

use toiletcli::common::{name_from_path};

let path = "toilet/bin/program";
let name = common::name_from_path(path);

assert_eq!(name, "program");