Skip to content

Discover and inject task parameters #286

@seaneagan

Description

@seaneagan

Followup of #281 in support of #175.

@Task annotated methods will be able to use the same exact API as unscripted to define method parameters that represent positionals, options, and flags, and have those discovered and injected with command-line arguments.

For example:

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions