Advertisement
dragonrun1

DeriveDisplayOrder does not order options correctly code

May 8th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 5.79 KB | None | 0 0
  1. #[macro_use]
  2. extern crate clap;
  3. use clap::{App, AppSettings, Arg, ArgGroup};
  4. fn main() {
  5.     let matches = App::new("rhp-cli")
  6.         .setting(AppSettings::DeriveDisplayOrder)
  7.         .version("0.0.1")
  8.         .author(crate_authors!())
  9.         .about(crate_description!())
  10.         .bin_name("rhp-cli")
  11.         .template("Usage: {bin} [options] [-f] <file> [--] [args...]
  12.   {bin} [options] -r <code> [--] [args...]
  13.   {bin} [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
  14.   {bin} [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
  15.   {bin} [options] -S <addr>:<port> [-t docroot]
  16.   {bin} [options] -- [args...]
  17.   {bin} [options] -a
  18.  
  19. {unified}
  20.  
  21. {positionals}")
  22.         .arg(Arg::with_name("interactive")
  23.             .short("a")
  24.             .help("Run interactively")
  25.             .takes_value(false)
  26.         )
  27.         .arg(Arg::with_name("php_ini")
  28.             .short("c")
  29.             .long("php-ini")
  30.             .help("Look for php.ini file in the <path> or in this <file>")
  31.             .takes_value(true)
  32.             .value_name("path|file")
  33.             .number_of_values(1)
  34.         )
  35.         .arg(Arg::with_name("no_php_ini")
  36.             .short("n")
  37.             .long("no-php-ini")
  38.             .overrides_with("php_ini")
  39.             .help("No php.ini file will be used")
  40.             .takes_value(false)
  41.         )
  42.         .arg(Arg::with_name("define")
  43.             .short("d")
  44.             .long("define")
  45.             .help("Define INI entry foo with value 'bar'")
  46.             .takes_value(true)
  47.             .value_name("foo[=bar]")
  48.             .multiple(true)
  49.         )
  50.         .arg(Arg::with_name("profile_info")
  51.             .short("e")
  52.             .long("profile-info")
  53.             .help("Generate extended information for debugger/profiler")
  54.         )
  55.         .arg(Arg::with_name("file")
  56.             .short("f")
  57.             .long("file")
  58.             .help("Parse and execute <file>")
  59.             .takes_value(true)
  60.             .number_of_values(1)
  61.         )
  62.         .arg(Arg::with_name("run")
  63.             .short("r")
  64.             .long("run")
  65.             .help("Run PHP <code> without using script tags <?..?>")
  66.             .takes_value(true)
  67.             .number_of_values(1)
  68.             .value_name("code")
  69.         )
  70.         .arg(Arg::with_name("server")
  71.             .short("S")
  72.             .long("server")
  73.             .help("Run with built-in web server")
  74.             .takes_value(true)
  75.             .number_of_values(1)
  76.             .value_name("[addr]:[port]")
  77.         )
  78.         .arg(Arg::with_name("zend_extension")
  79.             .short("z")
  80.             .long("zend-extension")
  81.             .help("Load Zend extension <file>")
  82.             .takes_value(true)
  83.             .value_name("file")
  84.         )
  85.         .arg(Arg::with_name("process_begin")
  86.             .short("B")
  87.             .long("process-begin")
  88.             .help("Run PHP <begin_code> before processing input lines")
  89.             .takes_value(true)
  90.             .value_name("begin_code")
  91.         )
  92.         .arg(Arg::with_name("process_code")
  93.             .short("R")
  94.             .long("process-code")
  95.             .help("Run PHP <code> for every input line")
  96.             .takes_value(true)
  97.             .value_name("code")
  98.         )
  99.         .arg(Arg::with_name("process_file")
  100.             .short("F")
  101.             .long("process-file")
  102.             .help("Parse and execute <file> for every input line")
  103.             .takes_value(true)
  104.             .value_name("file")
  105.         )
  106.         .arg(Arg::with_name("process_end")
  107.             .short("E")
  108.             .long("process-end")
  109.             .help("Run PHP <end_code> after processing all input lines")
  110.             .takes_value(true)
  111.             .value_name("end_code")
  112.         )
  113.         .arg(Arg::with_name("args")
  114.             .help("Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin")
  115.             .multiple(true)
  116.         )
  117.         .arg(Arg::with_name("ini")
  118.             .long("ini")
  119.             .help("Show configuration file names")
  120.         )
  121.         .arg(Arg::with_name("rclass")
  122.             .long("rc")
  123.             .help("Show information about class <name>")
  124.             .takes_value(true)
  125.             .value_name("name")
  126.             .alias("rclass")
  127.         )
  128.         .arg(Arg::with_name("rextension")
  129.             .long("re")
  130.             .help("Show information about extension <name>")
  131.             .takes_value(true)
  132.             .value_name("name")
  133.             .alias("rextension")
  134.         )
  135.         .arg(Arg::with_name("rextinfo")
  136.             .long("ri")
  137.             .help("Show configuration for extension <name>")
  138.             .takes_value(true)
  139.             .value_name("name")
  140.             .alias("rextinfo")
  141.         )
  142.         .arg(Arg::with_name("rfunction")
  143.             .long("rf")
  144.             .help("Show information about function <name>")
  145.             .takes_value(true)
  146.             .value_name("name")
  147.             .alias("rfunction")
  148.         )
  149.         .arg(Arg::with_name("rzendextension")
  150.             .long("rz")
  151.             .help("Show information about Zend extension <name>")
  152.             .takes_value(true)
  153.             .value_name("name")
  154.             .alias("rzendextension")
  155.         )
  156.         .arg(Arg::with_name("copy")
  157.             .help("Show copyright/license info")
  158.             .long("copy")
  159.             .visible_alias("license")
  160.         )
  161.         .group(ArgGroup::with_name("sapi")
  162.             .args(&["interactive", "file", "run", "server"])
  163.             .required(false)
  164.         )
  165.         .group(ArgGroup::with_name("cgi")
  166.             .args(&["bind_path", "no_chdir", "no_header", "timing"])
  167.             .required(false))
  168.         .get_matches();
  169.     println!("{:?}", matches);
  170.  
  171. }
  172. #[cfg(test)]
  173. mod tests {
  174.     use super::super::test::*;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement