Workiva / dart_dev

Centralized tooling for Dart projects. Consistent interface across projects. Easily configurable.
https://pub.dartlang.org/packages/dart_dev
Apache License 2.0
74 stars 40 forks source link

Take a look at pkg/completion #103

Open kevmoo opened 8 years ago

kevmoo commented 8 years ago

https://github.com/kevmoo/completion.dart

Manually writing completion scripts isn't a lot of fun – this just parties off pkg/args

Might be useful?

evanweible-wf commented 8 years ago

@kevmoo hadn't seen that before, thanks for posting it! I'll look into using this

georgelesica-wf commented 8 years ago

@kevmoo we're using completion.dart now (hooray!) We'd like to be able to provide a facility for doing something like below in a .bashrc or similar, but it doesn't appear to be possible.

source "$(pub global run dart_dev bash-completion)"

My intention was to just put the generated completion script in lib/ and then write the path to stdout. However, the Platform.script attribute is a URL when the app is run as a global, something like http://localhost:60270/dart_dev.dart, so we have no way of getting to lib/.

Another option would be to generate the script on the fly and use eval instead of source in the snippet above, but then we'd need to either install completions.dart globally and run it, or move most of the code in the completions.dart script into lib/ so the completions could be generated via Dart. I could do a quick PR to make that change, unless there's a workaround I'm not seeing...

kevmoo commented 8 years ago

@georgelesica-wf please file an issue on the completion package.

I'm guessing we have a way around this with recently added SDK APIs. Need to look into it.

kevmoo commented 8 years ago

@georgelesica-wf Actually, I'd say look at https://pub.dartlang.org/packages/package_config

This isn't anything to do with completion, I think. It's everything to do with getting to the lib dir from a globally activated package, right?

pkg/resource would be easier, but this only exposes the contents of the file – not the path.

georgelesica-wf commented 8 years ago

@kevmoo Oh cool, actually the content would probably be fine because we could just use the eval ... pattern in our documentation instead of source .... I'll give it a try, thanks!

kevmoo commented 8 years ago

@georgelesica-wf I am doing work so you can 'pub global activate completion' too.

It has a silly dependency on Platform.script being a file: URI at the moment. I'm fixing that up.