Discover and inject task parameters
- Dominant language
- Dart
- Stars
- 266
- Forks
- 36
- Avg merge
- 23h 25m
- Merged PRs (30d)
- 2
Description
Followup of #281 in support of #175.
`@Task` annotated methods will be able to use the same exact API as [unscripted](https://github.com/seaneagan/unscripted) to define method parameters that represent positionals, options, and flags, and have those discovered and injected with command-line arguments.
For example:
``` dart
@Task()
bump(
@Positional(help: 'The type of release being performed.', allowed: const ['major', 'minor', 'patch', 'build', 'release'])
String releaseType),
{@Option(help: 'Do a pre-release with this prefix e.g. "dev"')
String preId,
@Flag(help: 'Whether to do a pre-release')
bool pre} {
var args = ['bump', releaseType];
if (pre) args.add('--pre');
if (preId != null) args.addAll(['--pre-id', preId]);
new PubApp.global('den').run(args);
}
```
As in unscripted, all metadata (`Positional`, `Option`, `Flag` and their parameters) is optional.
This will require a lot of the same code existing in unscripted, so I may need to factor that out into a shared library or package along with some of the code that went in in #281.
Contributor guide
Assessment
This issue has not been assessed yet.