We're using completion.dart for a dev tool (dart_dev). We'd like to be able to provide a facility for doing something like below to register the completions 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 (which would make the above work). 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, which seems overly roundabout, or move most of the code in the completions.dart bin script into lib/ so the completions could be generated via Dart.
I will put up a PR that does the latter later today, but obviously if there is just a convenient way to get the path to a package's lib/, that would be the easiest way to get to where we want to be.
We're using completion.dart for a dev tool (dart_dev). We'd like to be able to provide a facility for doing something like below to register the completions in a
.bashrc
or similar, but it doesn't appear to be possible.My intention was to just put the generated completion script in
lib/
and then write the path to stdout (which would make the above work). However, thePlatform.script
attribute is a URL when the app is run as a global, something likehttp://localhost:60270/dart_dev.dart
, so we have no way of getting tolib/
.Another option would be to generate the script on the fly and use
eval
instead ofsource
in the snippet above, but then we'd need to either install completions.dart globally and run it, which seems overly roundabout, or move most of the code in the completions.dart bin script intolib/
so the completions could be generated via Dart.I will put up a PR that does the latter later today, but obviously if there is just a convenient way to get the path to a package's
lib/
, that would be the easiest way to get to where we want to be.