Skip to content

Implement task parameterization #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 9, 2015
Merged

Implement task parameterization #281

merged 3 commits into from
Jul 9, 2015

Conversation

seaneagan
Copy link
Contributor

@devoncarew

This allows defining parameters for tasks, and accepting arguments for them when invoking tasks either from the command-line or when used as dependencies.

It doesn't yet include:

  • An annotation based API (want to factor out that code from unscripted so that it can be shared here)
  • README and CHANGELOG updates (waiting for the annotation based API first)
  • Help output for task parameters
  • Tab-completion of positional and named values (option names should already be completed though)
  • Re-exporting unscripted's Option, Flag, Positional, and Rest (hesitant to do this).
  • Optional positionals are only supported via the Rest argument (multiple homogeneous args). Main reason is the same as it is for unscripted, which is that dart doesn't support having both named and positional optional parameters in the same signature, so they couldn't be defined through the forthcoming annotation based API. There may be a way to add it in the imperative API though.

I will file separate issues for each of these, once this one lands.

This PR also splits out most of lib/grinder.dart into smaller libraries under lib/src. I didn't intend on doing that in this PR, but I added a couple new libraries, and wanted to use just one small part of lib/grinder.dart so factored that part out, but then that depended on another small part, so had to factor that out as well, and it snowballed from there.

@@ -0,0 +1,267 @@
// Copyright 2015 Google. All rights reserved. Use of this source code is
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the methods in this file are not yet directly unit tested. That's because they are mostly copied and pasted from unscripted with slight modifications, and so I want to factor them out into a separate library or package that can be shared by unscripted and grinder. Plan to do that as part of implementing the annotation based API.

@devoncarew
Copy link
Contributor

It is a doozy - sorry for the delay in taking a look at it.

This PR also splits out most of lib/grinder.dart into smaller libraries under lib/src

This does make the PR harder to review - it's not easy to tell at a glance which changes are semantic ones...

That aside, given the size of the PR, the source code re-org, and the fact that it has some smaller breaking changes, I think we should push out a last minor release before this lands, and then plan on doing a full major rev. It'll capture this PR, give you some time to do the additional changes mentioned, and let us remove the 0.7 deprecated code.

addTask(new GrinderTask(
'bump',
taskFunction: () {
var releaseType = context.invocation.positionals.first;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make accessing the args more terse, or add aliases to help references to the args be terse?

context.args.rest.first;
context.args.first;
context.args['foo];

args.rest.first;
args['foo'];

thoughts? This: context.invocation.positionals.first strikes me as pretty long, given that it may be the most common use of task args.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't anticipate many folks actually needing to use the imperative API introduced in this PR, once I add the follow up annotation-based API which will look something like:

@Task('bump the version')
bump(
    @Positional(help: 'Which type of release to do', allowed: ['release', 'build', 'patch', 'minor', 'major'])
    String releaseType,
    {bool pre: false
     String preId}) {
  // ...
}

which is about as terse as it could possibly get.

The name invocation is to match TaskInvocation. I considered TaskArgs, which would match up with args, but that doesn't really capture the fact that it contains the task name as well. And "invocation" is already a familiar concept for anyone who has used dart:mirrors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, cool. The 95% case will be the annotations API, which will be nice and terse; makes sense.

@seaneagan
Copy link
Contributor Author

This does make the PR harder to review - it's not easy to tell at a glance which changes are semantic ones...

Yep, totally my fault. lib/grinder.dart was getting pretty unwieldy, so I added the new libraries separately, and then my habit of only depending on the parts I need from those libraries kicked in, and I didn't realize I was breaking the PR diffs until it was too late. FWIW, it was really nice working with the smaller libraries compared to endless scrolling up and down lib/grinder.dart trying to find things :).

That aside, given the size of the PR, the source code re-org, and the fact that it has some smaller breaking changes, I think we should push out a last minor release before this lands, and then plan on doing a full major rev. It'll capture this PR, give you some time to do the additional changes mentioned, and let us remove the 0.7 deprecated code.

Sounds good, so first #278 then merge this, then #138, then the follow up issues I mentioned above, then release 0.8?

@devoncarew
Copy link
Contributor

Sounds good, so first #278 then merge this, then #138, then the follow up issues I mentioned above, then release 0.8?

+1!

@devoncarew
Copy link
Contributor

OK, lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants