Index: g-cpan =================================================================== --- g-cpan (revision 98) +++ g-cpan (working copy) @@ -44,9 +44,13 @@ use Getopt::Long; Getopt::Long::Configure("bundling"); -# Init all options (has to be done to perform the 'sum test' later) -my ($debug, $verbose, $search, $install, $upgrade, $generate, $list, $pretend, $ask, $cpan_reload, $buildpkg, $buildpkgonly, $log) = - (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +# Declare options +# First, the main switches +my @main_switches = \my ($search, $list, $install, $generate, $ask, $buildpkg, $buildpkgonly); +# Then, additional switches +my @additional_switches = \my ($upgrade, $pretend); +# Then, the normal options +my ($debug, $verbose, $cpan_reload, $log); # Set colors here so we can use them at will anywhere :) my $green = color("bold green"); @@ -118,16 +122,18 @@ # Array that will contain the portage friendly version of the values passed to install my %really_install; -# Output error if more than one switch is activated +# Output error if more than one main switch is activated # -if ($search + $list + $install + $generate + $ask + $buildpkg + $buildpkgonly > 1) +# if ($search + $list + $install + $generate + $ask + $buildpkg + $buildpkgonly > 1) + +if ( (grep { defined $$_ } @main_switches) > 1) { print_err($prog, "You can't combine actions with each other.\n"); print_out("${white}Please consult ${cyan}$prog ${green}--help${reset} or ${cyan}man $prog${reset} for more information\n\n"); exit(); } -if ($search + $list + $install + $generate + $upgrade + $pretend + $ask + $buildpkg + $buildpkgonly == 0) +if ( ! grep { defined $$_ } @main_switches, @additional_switches ) { print_err($prog, "You haven't told $prog what to do.\n"); print_out("${white}Please consult ${cyan}$prog ${green}--help${reset} or ${cyan}man $prog${reset} for more information\n\n");