Skip to main content

tokenize

Function tokenize 

Source
pub fn tokenize(args: &[String]) -> Vec<Token>
Expand description

Tokenize a slice of CLI arguments into a vector of typed tokens.

Rules:

  1. -- alone emits EndOfOptions; everything after becomes Positional.
  2. --name or --name=val emits LongFlag.
  3. -x emits ShortFlag; -x=val emits ShortFlag with value; -abc (len > 2, no =) emits ShortCluster.
  4. - alone or -42 (dash + digit) emits Positional.
  5. Everything else emits Positional.