diff options
-rwxr-xr-x | bin/apt-why | 10 | ||||
-rw-r--r-- | provides/zsh/completions/_apt-why | 14 |
2 files changed, 15 insertions, 9 deletions
diff --git a/bin/apt-why b/bin/apt-why index f5c2093..893fd6f 100755 --- a/bin/apt-why +++ b/bin/apt-why @@ -11,22 +11,16 @@ use Getopt::Long; my $cache = AptPkg::Cache->new; my $max_depth = 5; my $all = 0; -my @deptypes; -my @default_deptypes = ('Depends', 'Recommends', 'Suggests'); +my @deptypes = ('Depends', 'Recommends', 'Suggests'); GetOptions( 'all!' => \$all, - 'deptype=s' => \@deptypes, + 'deptype=s' => sub {shift; @deptypes = split(/,/, shift)}, 'depth=i' => \$max_depth, 'h|?|help' => \&usage, ); my $packagename = shift or die("No packagename given"); my @known; -@deptypes = split(/,/, join(',', @deptypes)); -unless (@deptypes) { - @deptypes = @default_deptypes; -} - sub usage { exec('perldoc', '-F', $0) or die("See perldoc -F $0"); } diff --git a/provides/zsh/completions/_apt-why b/provides/zsh/completions/_apt-why index a014c45..20c39bb 100644 --- a/provides/zsh/completions/_apt-why +++ b/provides/zsh/completions/_apt-why @@ -6,10 +6,22 @@ typeset -a arguments +function _apt-why_deptype { + typeset prefix='' + typeset -a keys used_prefixes + keys=(Depends Recommends Suggests) + if [[ -prefix *, ]] { + prefix=${words[$CURRENT]%,*}, + used_prefixes=(${(s:,:)prefix}) + } + _wanted expression expl 'dependency type' \ + compadd -F used_prefixes -qS , -P "$prefix" $keys +} + arguments=( '--all[consider all available packages]' '--depth=-[recursion depth]:recursion depth' - '*--deptype=-[filter by dependency type]:dependency type:(Depends Recommends Suggests)' + '--deptype[filter by dependency type]:dependency type:_apt-why_deptype' '*:package:_deb_packages "" avail' ) |