11 stable releases

1.1.4 Jan 17, 2024
1.1.2 Nov 2, 2021
1.1.1 Nov 27, 2020
1.1.0 Jul 28, 2020
1.0.1 Nov 1, 2017

#79 in Command-line interface

Download history 101/week @ 2024-07-19 125/week @ 2024-07-26 122/week @ 2024-08-02 200/week @ 2024-08-09 200/week @ 2024-08-16 214/week @ 2024-08-23 288/week @ 2024-08-30 463/week @ 2024-09-06 245/week @ 2024-09-13 370/week @ 2024-09-20 433/week @ 2024-09-27 152/week @ 2024-10-04 595/week @ 2024-10-11 622/week @ 2024-10-18 297/week @ 2024-10-25 319/week @ 2024-11-01

1,849 downloads per month
Used in 6 crates (5 directly)

MIT license

67KB
1.5K SLoC

rustop

rs-graph crate iter-comprehensions docs

Introduction

A simple command line parser.

rustop is a simple command line parsing crate in the spirit of Ruby's trollop. It allows to write command line parameters in a type-safe way with as little effort as possible. rustop does not aim to be a full-featured command line parser for complex cases but to be a simple, easy to use crate for programs with a simple set of command line options.

Author

Frank Fischer frank-fischer@shadow-soft.de

Installation

Put the requirement rustop = "^1.1.4" into the Cargo.toml file of your project.

Documentation

See doc.rs.

Example

use rustop::opts;
fn main() {
    let (args, rest) = opts! {
        synopsis "This is a simple test program.";          // short info message for the help page
        opt verbose:bool, desc:"Be verbose.";               // a flag -v or --verbose
        opt luck:bool=true, desc:"We have no luck.";        // a flag -l or --no-luck
        opt number_of_lines:usize=1,
            desc:"The number of lines.";                    // an option -n or --number-of-lines
        param file:Option<String>, desc:"Input file name."; // an optional (positional) parameter
    }.parse_or_exit();

    if args.verbose {
        println!("Start the test program.");
    }

    if let Some(file) = args.file { println!("Read file: {}", file); }
    println!("Number of lines: {}", args.number_of_lines);
}

Download

Source code of latest tagged version: rustop-v1.1.4.tar.gz

Source code of trunk: rustop-trunk.tar.gz

No runtime deps