Discussion:
[Bug 1797290] [NEW] no bash-completion for pull-lp-source (and probably others)
Rolf Leggewie
2018-10-11 02:50:32 UTC
Permalink
Public bug reported:

It would be nice if the package offered bash-completion for pull-lp-
source and other binaries or CLI tools where appropriate. I just tried
"pull-lp-source wmcTAB" and expected it to complete to wmctrl.

** Affects: ubuntu-dev-tools (Ubuntu)
Importance: Undecided
Status: New


** Tags: bioinic
--
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1797290

Title:
no bash-completion for pull-lp-source (and probably others)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-dev-tools/+bug/1797290/+subscriptions
--
universe-bugs mailing list
universe-***@lists.ubuntu.com
https://lists.ubuntu.com/mailman/l
Dan Streetman
2018-10-15 15:34:26 UTC
Permalink
This has bugged me too, unless someone else gets to this first I'll take
a look at adding it.
--
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1797290

Title:
no bash-completion for pull-lp-source (and probably others)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-dev-tools/+bug/1797290/+subscriptions
--
universe-bugs mailing list
universe-***@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/un
Mattia Rizzolo
2018-10-15 19:36:09 UTC
Permalink
I recommend you look at python3-argcomplete for this :)
--
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1797290

Title:
no bash-completion for pull-lp-source (and probably others)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-dev-tools/+bug/1797290/+subscriptions
--
universe-bugs mailing list
universe-***@lists.ubuntu.com
https://lists.ubuntu.com/
Dan Streetman
2018-10-29 21:28:04 UTC
Permalink
python3-argcomplete does seem quite useful for complex pythonic autocompletion, but it seems to have downside as well - users will need to run a script to set it up first:
https://pypi.org/project/argcomplete/#activating-global-completion

am I misunderstanding that? Seems like a fairly big ask for users to
have to know to 'set up' their global argcomplete before it works at
all. Maybe the debian/ubuntu python[3]-argcomplete pkg should invoke
the global activation script on deb install?


plus, for this use case, it really does seem like just a good-old bash completion function is easier, at least to start with.

First, I think the "best" way to generate the list of autocomplete pkgs
would be to get the current list of all source and binary package names
from lp. However, that's basically a non-starter as it would take way,
way too long for autocomplete purposes. Caching it all would be good,
but (assuming we don't want to create a background cache update just for
this) it would prevent autocomplete until the cache was up to date.

As a compromise, I think using apt's package cache will be "good
enough", at least to start with. It's actually rather trivial to do
that; for quick testing:

$ _pullpkg() { local cur; _init_completion || return; COMPREPLY=($( apt-cache --no-generate pkgnames "$cur" 2> /dev/null )); return 0; }
$ complete -F _pullpkg pull-lp-source

After that, in the bash shell where you ran those cmds, pull-lp-source
should autocomplete any/all package names. Those 2 lines can be dropped
into ~/.bash_completion (or a file in /usr/share/bash-
completion/completions/ or /etc/bash_completions.d/) and all new shells
will pick up the autocompletion.

Unfortunately that still isn't quite perfect; for example there are lots
and lots (and lots and LOTS) of different kernel package names. If I'm
running bionic but I want to pull a specific kernel from trusty, the apt
autocompletion won't provide those package names (because each kernel
package has version-specific naming). It might be worth trying to use
the apt cache for the first 3 (or so) letters of a package name, but
after that switch to real LP querying (hopefully with caching). Or,
maybe we could use a LP package local cache, but if that's not populated
yet fall back to apt caching.

** Changed in: ubuntu-dev-tools (Ubuntu)
Assignee: (unassigned) => Dan Streetman (ddstreet)

** Changed in: ubuntu-dev-tools (Ubuntu)
Importance: Undecided => Low
--
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1797290

Title:
no bash-completion for pull-lp-source (and probably others)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-dev-tools/+bug/1797290/+subscriptions
--
universe-bugs mailing list
universe-***@lists.ubuntu.com
https://li
Loading...