cross-plat-dev-utils/usage.pm
changeset 2 39c28ec933dd
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 #!/usr/bin/perl
       
     2 # Copyright (c) 2010 Symbian Foundation Ltd
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Mike Kinghan, mikek@symbian.org, for Symbian Foundation Ltd - initial contribution.
       
    10 
       
    11 # Subroutine to emit a help message for a script when it is passed
       
    12 # -h or --help.
       
    13 
       
    14 use strict;
       
    15 
       
    16 sub usage(@)
       
    17 {
       
    18 	my ($argv_ref,@usage_lines) = @_;
       
    19 	if (@{$argv_ref}) {
       
    20 		if (grep(/$argv_ref->[0]/,("-h","--help"))) {
       
    21 			foreach my $line (@usage_lines) {
       
    22 				print "$line\n";
       
    23 			}
       
    24 			print "Needs no arguments\n";
       
    25 			exit 0;
       
    26 		}
       
    27 		print "Valid arguments are -h, --help, or none\n";
       
    28 		exit 1;
       
    29 	}
       
    30 }
       
    31 
       
    32 1;
       
    33