Open kevmoo opened 8 years ago
@kevmoo hadn't seen that before, thanks for posting it! I'll look into using this
@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...
@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.
@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.
@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!
@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.
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?