From 8ff347ad957b2174c56747a7d9bffa53fad1b228 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 20 Sep 2009 11:20:21 +0200 Subject: Added --tabwidth option; indent with tabs by default --- bin/apt-why | 21 ++++++++++++++++----- provides/zsh/completions/_apt-why | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/apt-why b/bin/apt-why index 991449c..e0e4123 100755 --- a/bin/apt-why +++ b/bin/apt-why @@ -10,12 +10,15 @@ use Getopt::Long; my $cache = AptPkg::Cache->new; my $max_depth = 5; my $all = 0; +my $tabwidth; +my $tabsign = "\t"; my @deptypes = ('Depends', 'Recommends', 'Suggests'); GetOptions( - 'all!' => \$all, - 'deptype=s' => sub {@deptypes = split(/,/, $_[1])}, - 'depth=i' => \$max_depth, - 'h|?|help' => \&usage, + 'all!' => \$all, + 'deptype=s' => sub {@deptypes = split(/,/, $_[1])}, + 'depth=i' => \$max_depth, + 'tabwidth=i' => \$tabwidth, + 'h|?|help' => \&usage, ); my $packagename = shift or die("No packagename given"); my @known; @@ -48,7 +51,7 @@ sub recurse { my $name = shift; my $depth = (shift) + 1; - printf("%s%s\n", " " x ($depth-1), $name); + printf("%s%s\n", $tabsign x ($depth-1), $name); if ($depth >= $max_depth) { return; @@ -61,6 +64,10 @@ sub recurse { return; } +if (defined $tabwidth) { + $tabsign = ' ' x $tabwidth; +} + if (not defined $cache->{$packagename}) { print STDERR "No such package: $packagename\n"; exit(1); @@ -104,6 +111,10 @@ Specify the maximum recursion depth Only show reverse dependency which mach the specified I (comma separated list). Right now, possible types are Depends, Suggests, Recommends. +=item B<--tabwidth>=I + +Indent each recursion level with I spaces (by default: one tab) + =back =head1 AUTHOR diff --git a/provides/zsh/completions/_apt-why b/provides/zsh/completions/_apt-why index 20c39bb..78391ca 100644 --- a/provides/zsh/completions/_apt-why +++ b/provides/zsh/completions/_apt-why @@ -22,6 +22,7 @@ arguments=( '--all[consider all available packages]' '--depth=-[recursion depth]:recursion depth' '--deptype[filter by dependency type]:dependency type:_apt-why_deptype' + '--tabwidth=-[spaces per recursion level]:spaces per recursion level' '*:package:_deb_packages "" avail' ) -- cgit v1.2.3