clars 0.3.0

Command line arguments resolver
Documentation
use super::*;

fn clar() -> Clar {
  Clar::new(APP).options_commands(
    [ClarOption::new("help", 'h', "help").standalone(), ClarOption::new("color", 'c', "color")],
    [
      ClarCommand::new("a").options([ClarOption::new("help", 'h', "help").standalone()]),
      ClarCommand::new("b").options([ClarOption::new("verbose", 'v', "verbose").standalone()]),
      ClarCommand::new("c"),
    ],
  )
}

#[test]
fn _0001() {
  assert!(clar().resolve(["-h"]).unwrap().is_present("help"));
}

#[test]
fn _0002() {
  let matches = clar().resolve(["-c", "b"]).unwrap();
  assert!(matches.is_present("color"));
  assert!(matches.is_present("b"));
}

#[test]
fn _0003() {
  assert_eq!("option '-h' must be used alone", clar().resolve(["-h", "-V"]).unwrap_err().to_string());
}

#[test]
fn _0004() {
  assert!(clar().resolve(["a"]).unwrap().is_present("a"));
}

#[test]
fn _0005() {
  assert!(clar().resolve(["a", "-h"]).unwrap().is_present("a"));
  assert!(clar().resolve(["a", "-h"]).unwrap().is_present(["a", "help"]));
}

#[test]
fn _0006() {
  assert!(clar().resolve(["b", "-v"]).unwrap().is_present("b"));
  assert!(clar().resolve(["b", "--verbose"]).unwrap().is_present(["b", "verbose"]));
}

#[test]
fn _0007() {
  assert_eq!("option '-h' must be used alone", clar().resolve(["a", "-h", "-v"]).unwrap_err().to_string());
}

#[test]
fn _0008() {
  assert_eq!(
    "option '--verbose' must be used alone",
    clar().resolve(["b", "--verbose", "-h"]).unwrap_err().to_string()
  );
}