On Sun, Jul 07, 2019 at 05:44:28PM -0400, Kurt Mosiejczuk wrote:
> Currently, if you give an unknown port type to portgen it dies with 
> "unknown module type\n". This doesn't reflect what the rest of the code
> or the manpage uses to refer to the first argument: "type". So, correct
> that, along with outputting the offending input.
> 
> While here, tell the user what the valid choices are.

Maybe we can be more informative right off the bat?  I'm not sure I like
my wording any better than yours, so maybe a combination, or maybe
someone has a better idea.


> 
> --Kurt
> 
> Index: portgen
> ===================================================================
> RCS file: /cvs/ports/infrastructure/bin/portgen,v
> retrieving revision 1.1
> diff -u -p -r1.1 portgen
> --- portgen   18 Jan 2016 19:01:02 -0000      1.1
> +++ portgen   7 Jul 2019 21:41:23 -0000
> @@ -45,7 +45,7 @@ if ( $type eq 'p5' ) {
>  } elsif ( $type eq 'ruby' ) {
>       $o = OpenBSD::PortGen::Port::Ruby->new();
>  } else {
> -     die "unknown module type\n";
> +     die "unknown type: " . $type . "\nknown types: p5, py, ruby\n";
>  }
>  
>  my @new_ports = $o->port($module);
> 

Index: infrastructure/bin/portgen
===================================================================
RCS file: /cvs/ports/infrastructure/bin/portgen,v
retrieving revision 1.1
diff -u -p -r1.1 portgen
--- infrastructure/bin/portgen  18 Jan 2016 19:01:02 -0000      1.1
+++ infrastructure/bin/portgen  8 Jul 2019 00:05:15 -0000
@@ -35,7 +35,8 @@ use OpenBSD::PortGen::Port::Ruby;
 
 my ( $type, $module ) = @ARGV;
 
-die "usage: portgen type module\n" unless $type and $module;
+my $usage = "usage: portgen p5|py|ruby module\n";
+die $usage unless $type and $module;
 
 my $o;
 if ( $type eq 'p5' ) {
@@ -45,7 +46,7 @@ if ( $type eq 'p5' ) {
 } elsif ( $type eq 'ruby' ) {
        $o = OpenBSD::PortGen::Port::Ruby->new();
 } else {
-       die "unknown module type\n";
+       die $usage;
 }
 
 my @new_ports = $o->port($module);

Reply via email to