Crate getopt3

source ·
Expand description

getopt(3) parser

Command line argument parser similar to POSIX getopt with GNU ‘–’ extension.

getopt3::new parses the command line elements and isolates arguments from options. It returns a getopt struct where you can query options and use isolated arguments.

An element that starts with ‘-’ (and is not exactly “-” or “–”) is an option element. The characters of this element (aside from the initial ‘-’) are option characters.

Example
use std::env::args;
let rc = getopt3::new(args(), "ab:c");
if let Ok(g) = rc {
   // command line options parsed sucessfully
   if let Some(str) = g.options.get(&'b') {
      // handle b argument
   };
};
Reference

POSIX getopt function.

Structs

  • Parsed command line options.

Functions

  • Parse command line arguments.
  • Validate parsed options.