Skip to content

Refactor grinderArgs() #116

Open
Open
@seaneagan

Description

@seaneagan

The purpose of grinderArgs() it is to be able to access custom command-line arguments from tasks. However, package:args currently doesn't allow unknown options to be passed anyway (arg parsing will fail). Ideally a task could declare its own custom command-line options and flags. That would allow:

  • including help text for them via grind -h
  • validating custom command-line arguments with task arguments.

It would be really cool to reuse unscripted's Flag and Option annotations:

@Task('Deploy the project.')
deploy(
  @Option(allowed: const ['local', 'ci', 'test', 'prod'], help: 'Which environment to deploy to.')
  String env) {
  // ...
}

Then grind -h would include something like:

[deploy] Deploy the project.
  --env    Which environment to deploy to.

If we do keep grinderArgs(), I think it should be a getter, and probably move it to GrinderContext, or integrate with whatever solution we do for dart-lang/core#31.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions