File | parse-options.str |
Author | unknown |
Since | unknown |
Strategies for handling command-line options.
Example:---------------------------------------------------------------------------module option-demoimports options
strategies
main =io-wrap(demo-options, demo-usage, default-system-about, demo-impl)
demo-impl = id
demo-options =Option("--option1", <set-config> ("--option1", ()), !"--option1 This is a an example option")+ ArgOption("--arg1", <set-config> ("--arg1", <id>), !"--arg1 This is an example arg option")
demo-usage =default-system-usage(!"Usage: option-demo [options]", !" This is a test program to demonstrate use ofparse-options and generation of usage infofrom option and switch specificatios. Thesenow contain usage info as additional third argument.")---------------------------------------------------------------------------
option-demo --help now displays:---------------------------------------------------------------------------Usage: option-demo [options]
Options:--option1 This is a an example option--arg1 This is an example arg option-i f|--input f Read input from f-o f|--output f Write output to f-b Write binary output-S|--silent Silent execution (same as --verbose 0)--verbose i Verbosity level i (default 1)-s Turn on statistics-k i | --keep i Keep intermediates (default 0)-h|-?|--help Display usage information--about Display information about this program--version Same as --about
Description:This is a test program to demonstrate use ofparse-options and generation of usage infofrom option and switch specificatios. Thesenow contain usage info as additional thirdargument.---------------------------------------------------------------------------
General | |
Lines of code | 344 |
Stratego | |
Module number | 1 (100% documented) |
Constructor number | 2 (0% documented) |
Overlay number | 0 |
Strategy number | 35 (60% documented) |
Rule number | 6 (33% documented) |
DynamicRule number | 0 |
Constructor summary |
||
Program(ATerm ) | n/a | parse-options.str |
Undefined(ATerm ) | n/a | parse-options.str |
Strategy summary |
||
Arg2Option(Strategy is-flag, Strategy label) | n/a | parse-options.str |
Arg2Option(Strategy is-flag, Strategy label, Strategy s) | n/a | parse-options.str |
ArgOption(Strategy is-flag, Strategy label) | n/a | parse-options.str |
ArgOption(Strategy is-flag, Strategy label, Strategy s) | n/a | parse-options.str |
ArgOption(Strategy is-flag, Strategy handlers, ATerm msg) | Handle a special action, which is specified by a tuple | parse-options.str |
default-system-about | Just shows the name of the program | parse-options.str |
default-system-usage | Default system usage that invokes the short-description and long-description hook | parse-options.str |
default-system-usage(Strategy short, Strategy long) | Display usage info containing a short description of the program | parse-options.str |
long-description(Strategy s) | No default short description | parse-options.str |
Option(Strategy is-flag, Strategy label) | n/a | parse-options.str |
Option(Strategy is-flag, Strategy label, Strategy s) | Registere usage info, when Option is applied to the term "register-usage-info" | parse-options.str |
Option(Strategy is-flag, Strategy handlers, ATerm msg) | Handle a special action, which is specified by a tuple | parse-options.str |
option-defined(Strategy s) | n/a | parse-options.str |
OptionCheck(Strategy exit, Strategy checks, ATerm msg) | The exit parameter can - be <exit> 1 for immediate failure - be <set-config> "--help" to report the usage and exit | parse-options.str |
OptionHandler(Strategy user) | n/a | parse-options.str |
OptionHandler(Strategy init, Strategy user, Strategy default) | n/a | parse-options.str |
OptionHandler(Strategy init, Strategy user, Strategy default) | n/a | parse-options.str |
OptionHandler(Strategy init, Strategy user, Strategy default) | n/a | parse-options.str |
OptionHandlerHelper(Strategy is-flag, Strategy handlers) | n/a | parse-options.str |
OptionHandlerHelper(Strategy is-flag, Strategy handlers) | n/a | parse-options.str |
OptionNotCombinedCheck(Strategy is-flag, Strategy other-flags) | Checks that this option is not used together with other options | parse-options.str |
OptionOneCheck(Strategy is-flag) | Checks that this option is used exactly once | parse-options.str |
OptionOneOrMoreCheck(Strategy is-flag) | Checks that this option is used one or more times | parse-options.str |
OptionZeroOrOneCheck(Strategy is-flag) | Checks that this option is specified just once, or not at all | parse-options.str |
override-system-about | No override of the default system about | parse-options.str |
override-system-usage | No override of the default system usage | parse-options.str |
parse-options(Strategy s) | Invokes system-usage and system-about on help and about | parse-options.str |
parse-options(Strategy s, Strategy usage, Strategy about) | Parse options | parse-options.str |
parse-options'(Strategy s) | Register all usages of all defined switches; then parse switches as specified by the user | parse-options.str |
register-usage(Strategy s) | Register useage info 's' by storing 's' in the table "usage-table" | parse-options.str |
short-description(Strategy s) | No default long description | parse-options.str |
system-about | n/a | parse-options.str |
system-about-switch | Always provide the --about and --version switch | parse-options.str |
system-usage | n/a | parse-options.str |
system-usage-switch | Always provide --help switch | parse-options.str |
Rule summary |
||
Arg2Option(Strategy is-flag, Strategy label, Strategy s) | n/a | parse-options.str |
ArgOption(Strategy is-flag, Strategy label, Strategy s) | n/a | parse-options.str |
ArgOption(Strategy is-flag, Strategy handlers, ATerm msg) | The handlers argument of this ArgOption variant must be an OptionHandler | parse-options.str |
Option(Strategy is-flag, Strategy label, Strategy s) | n/a | parse-options.str |
Option(Strategy is-flag, Strategy handlers, ATerm msg) | The handlers argument of this ArgOption variant must be an OptionHandler | parse-options.str |
UndefinedOption | n/a | parse-options.str |
Strategy details |
|||||||||
ATerm | ArgOption(Strategy is-flag, Strategy handlers, ATerm msg) | ||||||||
Handle a special action, which is specified by a tuple. |
|||||||||
ATerm | default-system-about | ||||||||
Just shows the name of the program. |
|||||||||
ATerm | default-system-usage | ||||||||
Default system usage that invokes the short-description and long-description hook. |
|||||||||
ATerm | default-system-usage(Strategy short, Strategy long) | ||||||||
Display usage info containing a short description of the program., ifdefined, followed by the usages of all switches. Finally, the longdescription of the program is displayed when it is defined. |
|||||||||
ATerm | long-description(Strategy s) | ||||||||
No default short description. Overrule to include in usage info. |
|||||||||
ATerm | Option(Strategy is-flag, Strategy label, Strategy s) | ||||||||
Registere usage info, when Option is applied to the term "register-usage-info" |
|||||||||
ATerm | Option(Strategy is-flag, Strategy handlers, ATerm msg) | ||||||||
Handle a special action, which is specified by a tuple. |
|||||||||
ATerm | OptionCheck(Strategy exit, Strategy checks, ATerm msg) | ||||||||
The exit parameter can- be <exit> 1 for immediate failure- be <set-config> "--help" to report the usage and exit.- not fail: failure will silently be ignored |
|||||||||
ATerm | OptionNotCombinedCheck(Strategy is-flag, Strategy other-flags) | ||||||||
Checks that this option is not used together with other options. |
|||||||||
ATerm | OptionOneCheck(Strategy is-flag) | ||||||||
Checks that this option is used exactly once. |
|||||||||
ATerm | OptionOneOrMoreCheck(Strategy is-flag) | ||||||||
Checks that this option is used one or more times. |
|||||||||
ATerm | OptionZeroOrOneCheck(Strategy is-flag) | ||||||||
Checks that this option is specified just once, or not at all. |
|||||||||
ATerm | override-system-about | ||||||||
No override of the default system about. |
|||||||||
ATerm | override-system-usage | ||||||||
No override of the default system usage. |
|||||||||
ATerm | parse-options(Strategy s) | ||||||||
Invokes system-usage and system-about on help and about. |
|||||||||
ATerm | parse-options(Strategy s, Strategy usage, Strategy about) | ||||||||
Parse options. Add system-usage switch and display usage info when userspecified '-h' switch. |
|||||||||
ATerm | parse-options'(Strategy s) | ||||||||
Register all usages of all defined switches; then parse switches asspecified by the user. |
|||||||||
ATerm | register-usage(Strategy s) | ||||||||
Register useage info 's' by storing 's' in the table "usage-table".Use fail, such that program execution continues with the nextalternative Option or ArgOption. This way we collect all usage info. |
|||||||||
ATerm | short-description(Strategy s) | ||||||||
No default long description. Overrule to include program description in usage info. |
|||||||||
ATerm | system-about-switch | ||||||||
Always provide the --about and --version switch. |
|||||||||
ATerm | system-usage-switch | ||||||||
Always provide --help switch. |
|||||||||
Rule details |
|||||||||
ATerm | ArgOption(Strategy is-flag, Strategy handlers, ATerm msg) | ||||||||
The handlers argument of this ArgOption variant must be an OptionHandler. |
|||||||||
ATerm | Option(Strategy is-flag, Strategy handlers, ATerm msg) | ||||||||
The handlers argument of this ArgOption variant must be an OptionHandler. |
|||||||||