Crates.io | rustop |
lib.rs | rustop |
version | 1.1.4 |
source | src |
created_at | 2017-08-01 06:43:25.678965 |
updated_at | 2024-01-17 09:34:50.471865 |
description | A simple command line parser. |
homepage | https://chiselapp.com/user/fifr/repository/rustop |
repository | https://chiselapp.com/user/fifr/repository/rustop |
max_upload_size | |
id | 25946 |
size | 67,955 |
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.
Frank Fischer frank-fischer@shadow-soft.de
Put the requirement rustop = "^1.1.4"
into the Cargo.toml
file of your project.
See doc.rs.
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);
}
Source code of latest tagged version: rustop-v1.1.4.tar.gz
Source code of trunk: rustop-trunk.tar.gz