Changeset 894
- Timestamp:
- Jun 26, 2010, 2:40:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dasscm/trunk/usr/bin/dasscm
r893 r894 8 8 qw($DASSCM_PROD $DASSCM_REPO $USER $DASSCM_USERNAME $DASSCM_USER $DASSCM_PASSWORD $SHELL); 9 9 use Cwd; 10 use Getopt::Long ;10 use Getopt::Long qw(GetOptionsFromArray); 11 11 use File::Basename; 12 12 use File::Compare; … … 18 18 use Term::ReadKey; 19 19 20 #use Data::Dumper;20 use Data::Dumper; 21 21 22 22 ##################################################################### … … 39 39 my $config_file = "/etc/dasscm.conf"; 40 40 my $config = get_config($config_file); 41 42 my @OPTIONS_GLOBAL = ( 'help', 'verbose' ); 41 43 42 44 my %COMMANDS = ( … … 1568 1570 sub complete(@) 1569 1571 { 1570 use Data::Dumper;1571 1572 my $number_arguments = @_;1573 1572 my @input = @_; 1574 1575 # TODO: check global options 1576 1577 if ( $number_arguments <= 1 ) { 1578 1579 # complete dasscm commands 1580 my $input = $input[0] || ""; 1581 map { m/^$input/ && print $_, "\n" } ( keys %COMMANDS ); 1582 } else { 1583 1584 # complete dasscm parameter 1585 my $command = get_command_uniform_name( $input[0] ); 1586 my @params = get_command_possible_params( $input[0] ); 1587 if ($verbose) { print "params: ", Dumper(@params); } 1588 1589 # arg 1: dasscm 1590 # arg 2: command 1591 # arg 3-x: parameter, therefore parameter_number = $number_arguments - 2 1592 my $parameter_number = $number_arguments - 2; 1593 if ( defined( $params[$parameter_number] ) 1594 && $params[$parameter_number] ) 1595 { 1596 my $param = $params[$parameter_number]; 1597 if ($verbose) { print "param used: ", $param, "\n"; } 1598 if ( $param eq "PATH_PROD" ) { 1599 complete_path( $input[ $number_arguments - 1 ] ); 1600 } elsif ( $param eq "PATH_REPO" ) { 1601 complete_repopath( $input[ $number_arguments - 1 ] ); 1573 my %options_complete = (); 1574 1575 # check and remove global options. if options are wrong, nothing to do 1576 if( GetOptionsFromArray( \@input, \%options_complete, @OPTIONS_GLOBAL ) ) { 1577 my $number_arguments = @input; 1578 if ( $number_arguments <= 1 ) { 1579 1580 # complete dasscm commands 1581 my $input = $input[0] || ""; 1582 map { m/^$input/ && print $_, "\n" } ( keys %COMMANDS ); 1583 } else { 1584 1585 # complete dasscm parameter 1586 my $command = get_command_uniform_name( $input[0] ); 1587 my @params = get_command_possible_params( $input[0] ); 1588 if ($verbose) { print "params: ", Dumper(@params); } 1589 1590 # arg 1: dasscm 1591 # arg 2: command 1592 # arg 3-x: parameter, therefore parameter_number = $number_arguments - 2 1593 my $parameter_number = $number_arguments - 2; 1594 if ( defined( $params[$parameter_number] ) 1595 && $params[$parameter_number] ) 1596 { 1597 my $param = $params[$parameter_number]; 1598 if ($verbose) { print "param used: ", $param, "\n"; } 1599 if ( $param eq "PATH_PROD" ) { 1600 complete_path( $input[ $number_arguments - 1 ] ); 1601 } elsif ( $param eq "PATH_REPO" ) { 1602 complete_repopath( $input[ $number_arguments - 1 ] ); 1603 } 1602 1604 } 1603 1605 } … … 1667 1669 # stops at first non-option 1668 1670 Getopt::Long::Configure( 'require_order' ); 1669 if( not GetOptions( \%options, 'help', 'verbose') ) {1671 if( not GetOptions( \%options, @OPTIONS_GLOBAL ) ) { 1670 1672 usage(); 1671 1673 exit $RETURN_NOK;
Note:
See TracChangeset
for help on using the changeset viewer.