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

`pub run` syntax not optimzed for common use cases #22129

Closed
DartBot opened this Issue Jan 22, 2015 · 11 comments

Comments

Projects
None yet
4 participants
@DartBot
Copy link

DartBot commented Jan 22, 2015

This issue was originally filed by @seaneagan


Currently to run grinder using pub run, it's:

  pub run grinder:grinder

This may be somewhat subjective, but running scripts exposed by other packages bin directories like this seems like the most common use case, however the most convenient syntax:

  pub run foo

currently runs a script from the current (in development) package's bin dir, which I can't think of many use cases for, since generally during development you want to run scripts from your tool directory.

I think the ideal would be to have:

  pub run grinder

be short for:

  pub run grinder:grinder

which runs the grinder package's bin/grinder.dart. Then to run scripts in the current package tool dir it could be:

  pub run :script

or to run a script in another directory of the current package:

  pub run :test/test

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jan 22, 2015

This comment was originally written by @seaneagan


Next best would be just having:

  pub run foo

run tool/foo.dart instead of bin/foo.dart from the current package.

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jan 23, 2015

This comment was originally written by @seaneagan


Also, it would be more consistent with pub global run. Since these are equivalent:

  pub global run foo
  pub global run foo:foo

These should be equivalent:

  pub run foo
  pub run foo:foo

@dgrove

This comment has been minimized.

Copy link
Member

dgrove commented Jan 23, 2015

Added Area-Pub, Triaged labels.

@nex3

This comment has been minimized.

Copy link
Member

nex3 commented Jan 26, 2015

I agree that "pub run grinder" should run "pub run grinder:grinder", but I don't think we should make it more difficult to run local scripts. The behavior I'd like for "pub run $ident" would be to look for "bin/$ident.dart" in the local package first, and if that doesn't exist run "bin/$ident.dart" in the $ident package.

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jan 26, 2015

This comment was originally written by @seaneagan


I like your shadowing proposal, though I'd tweak it to look in "tool" instead of "bin" in the local package.

For example, with grinder the convention is to put your grinder script at "tool/grind.dart" (which could easily be changed to "tool/grinder.dart"), not "bin/grinder.dart".

@nex3

This comment has been minimized.

Copy link
Member

nex3 commented Jan 26, 2015

Bob and I talked about this and we think you're right. We'd like a different syntax for running local executables, though; "pub run $path" should run a local executable at $path if $path isn't a Dart identifier (presumably because it contains directory separators and/or file extensions).

This will be a breaking change for running local packages, though, which means we should first add a deprecation message for the old "pub run $ident" syntax that points to the new syntax.

If you want to take a crack at this, Sean, we'd welcome your help.

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jan 26, 2015

This comment was originally written by @seaneagan


So, these would be equivalent:

  pub run foo
  pub run foo:foo

regardless of whether the local package has any foo scripts. And to run a local script you must specify the containing directory:

  pub run bin/foo
  pub run tool/foo

Sounds good to me, though it might be nice not to have to specify "tool/" by using the shadowing logic.

I would love to help out with that change, but I may wait to see if the pub code base moves to github as that'd make it much easier for me.

@nex3

This comment has been minimized.

Copy link
Member

nex3 commented Jan 26, 2015

I don't think primary pub development is moving to GitHub in the near future, unfortunately. It needs to access dart2js's source, which is tightly tied to the repo. If you'd like to use git, though, you could use the GitHub mirror of the repo: https://github.com/dart-lang/bleeding_edge/

@nex3

This comment has been minimized.

Copy link
Member

nex3 commented Mar 31, 2015

Set owner to @nex3.
Added Pub-Run, Started labels.

@nex3

This comment has been minimized.

Copy link
Member

nex3 commented Mar 31, 2015

r44819 implements this with a deprecation warning. I'm going to keep this issue open until after 1.10 is released, at which point we should remove the deprecation warning.


Added Accepted label.

@DartBot

This comment has been minimized.

Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/pub#1235.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment