-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from aminya/fixes
Fix the quick example
- Loading branch information
Showing
2 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import args : Arg, Optional, parseArgsWithConfigFile, printArgsHelp; | ||
|
||
static struct MyOptions { | ||
@Arg("the input file", Optional.yes) string inputFilename; | ||
@Arg("test values", 't') int[] testValues; | ||
@Arg("Enable feature") bool enableFeature; | ||
} | ||
|
||
MyOptions getOptions(ref string[] args) { | ||
MyOptions options; | ||
|
||
bool helpWanted = parseArgsWithConfigFile(options, args); | ||
|
||
if (helpWanted) { | ||
printArgsHelp(options, "A text explaining the program"); | ||
} | ||
return options; | ||
} | ||
|
||
void main(string[] args) { | ||
const options = getOptions(args); // or args.dup to keep the original args | ||
|
||
// use options here.... | ||
} |