mirror of
https://github.com/gay-pizza/jaarg.git
synced 2025-12-19 07:20:18 +00:00
Move help text and required flag to with chain, make help text optional
This commit is contained in:
@@ -203,11 +203,11 @@ pub fn main() -> ExitCode {
|
||||
// Read & parse arguments from the command line, store results into the above structure
|
||||
enum Arg { Out, Bin, Txt, Whitespace, Help }
|
||||
const OPTIONS: Opts<Arg> = Opts::new(&[
|
||||
Opt::help_flag(Arg::Help, &["--help", "-h"], "Show this help message and exit"),
|
||||
Opt::positional_required(Arg::Out, "out", "Path to generated header file"),
|
||||
Opt::value(Arg::Bin, &["--bin", "-b"], "data.bin", "Add a binary file"),
|
||||
Opt::value(Arg::Txt, &["--txt", "-t"], "text.txt", "Add a text file"),
|
||||
Opt::value(Arg::Whitespace, &["--whitespace"], "\" \"", "Emitted indentation (Default: \"\\t\")"),
|
||||
Opt::help_flag(Arg::Help, &["--help", "-h"]).help_text("Show this help message and exit"),
|
||||
Opt::positional(Arg::Out, "out").help_text("Path to generated header file").required(),
|
||||
Opt::value(Arg::Bin, &["--bin", "-b"], "data.bin").help_text("Add a binary file"),
|
||||
Opt::value(Arg::Txt, &["--txt", "-t"], "text.txt").help_text("Add a text file"),
|
||||
Opt::value(Arg::Whitespace, &["--whitespace"], "\" \"").help_text("Emitted indentation (Default: \"\\t\")"),
|
||||
]);
|
||||
match OPTIONS.parse_easy(|program_name, id, _opt, _name, arg| {
|
||||
match id {
|
||||
|
||||
@@ -8,10 +8,10 @@ use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
const OPTIONS: Opts<&'static str> = Opts::new(&[
|
||||
Opt::help_flag("help", &["--help"], "Show this help"),
|
||||
Opt::positional("positional", "positional", "Positional argument"),
|
||||
Opt::value("value", &["-v", "--value"], "string", "Value option"),
|
||||
Opt::flag("flag", &["-f", "--flag"], "Flag option"),
|
||||
Opt::help_flag("help", &["--help"]).help_text("Show this help"),
|
||||
Opt::positional("positional", "positional").help_text("Positional argument"),
|
||||
Opt::value("value", &["-v", "--value"], "string").help_text("Value option"),
|
||||
Opt::flag("flag", &["-f", "--flag"]).help_text("Flag option"),
|
||||
]);
|
||||
|
||||
let map = match OPTIONS.parse_map_easy() {
|
||||
|
||||
Reference in New Issue
Block a user