dart-lang / args

A command-line argument parsing library for Dart.

Home Page:https://pub.dev/packages/args

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: mandatory arguments

mschwartz opened this issue · comments

While we can have mandatory flags/options, we cannot have mandatory rest type arguments.

For example, a Command that implements *nix style cp command might want to require two mandatory arguments: source and destination.

As it is now, we have to check rest parameters within each run() function and print help if not the correct number of rest parameters.

Something like argParser.mandatory(2) would work for the cp example. Default value would be 0, as a Command like 'ls' doesn't require any mandatory arguments.

In the same reasoning, we could/should also have help for the mandatory arguments. For the cp example:

parser.mandatory(2, mandatoryHelp: ['source file to copy', 'destination path to copy to']);

This is a rough idea, it should be flushed out further.

The takesArguments member variable can be overriden to effect a mandatory(0) situation. However, setting taksArguments (@OverRide) does not affect the output of printUsage(). That is, I see [arguments] on the "Usage:" line of the output.