Changeset 887
- Timestamp:
- Jun 26, 2010, 12:03:52 AM (14 years ago)
- Location:
- dasscm/trunk
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dasscm/trunk/usr/bin/dasscm
r884 r887 62 62 'permissions' => 'permissions', 63 63 'cleanup' => 'cleanup', 64 'complete' => 'complete' 64 'complete' => 'complete', 65 'complete_path' => 'complete_path', 66 'complete_repopath' => 'complete_repopath', 65 67 ); 66 68 … … 91 93 'ls' => { 92 94 'desc' => [], 93 'params' => [ " PATH" ],95 'params' => [ "REPOPATH" ], 94 96 'function' => \&ls 95 97 }, … … 107 109 'commit' => { 108 110 'desc' => [], 109 'params' => [ " PATH" ],111 'params' => [ "REPOPATH" ], 110 112 'require' => [ "WRITE" ], 111 113 'function' => \&commit … … 151 153 'function' => \&complete 152 154 }, 155 'complete_path' => { 156 'desc' => [ "internally, used for bash completion" ], 157 'params' => [], 158 'function' => \&complete_path 159 }, 160 'complete_repopath' => { 161 'desc' => [ "internally, used for bash completion" ], 162 'params' => [], 163 'function' => \&complete_repopath 164 }, 153 165 ); 154 166 … … 196 208 print "\n"; 197 209 print "Available subcommands:\n"; 198 # print " help <subcommand>\n";199 # print " init\n";200 # print " login <username>\n";201 # print " up <path>\n";202 # print " ls <path>\n";203 # print " add <path>\n";204 # print " commit <path>\n";205 # print " revert <path>\n";206 # print " diff <path>\n";207 # print " status <path>\n";208 # print " check\n";209 # print " cleanup\n";210 # print " permissions\n";211 210 foreach my $i (sort keys(%COMMAND_DEFINITIONS)) { 212 211 print " ", $i, " ", join( " ", get_command_possible_params($i) ), "\n"; … … 313 312 } 314 313 } 314 $DASSCM_REPO = normalize_path($DASSCM_REPO); 315 315 if ($verbose) { print "DASSCM_REPO: " . $DASSCM_REPO . "\n"; } 316 316 … … 472 472 $path =~ s|/[/]*|/|g; 473 473 474 # remove self reference path 475 $path =~ s|/./|/|g; 476 474 477 return $path; 475 478 } … … 490 493 } 491 494 492 # file must be readable. Only exception is, when file should be reverted 493 if ( $command ne "revert" ) { 495 # file must be readable. 496 # The only exceptions are, 497 # - if the file parameter is to be completed or 498 # - if a file should be reverted 499 if ( $command ne "revert" && $command !~ m/^complete/ ) { 494 500 if ( not -r $filename_prod ) { 495 501 fatalerror( $filename_prod . " is not accessable" ); … … 1519 1525 1520 1526 my $number_arguments = @_; 1521 my $input_command = $_[0] || "";1522 1523 print "args: $number_arguments\n";1527 my @input = @_; 1528 1529 1524 1530 if ( $number_arguments <= 1 ) { 1525 1531 1532 # complete dasscm commands 1533 my $input = $input[0] || ""; 1526 1534 foreach my $i ( keys %COMMANDS ) { 1527 #print "$i: ";1528 #print get_command_requires_write( $i ), " ";1529 1535 $_ = $i; 1530 if( m/^$input _command/ ) {1536 if( m/^$input/ ) { 1531 1537 my $command = get_command_uniform_name($i); 1532 print $command, " "; 1533 print join( ",", get_command_possible_params($i) ) ; 1534 #print " (", get_command_desc( $i ), ") "; 1535 print "\n"; 1538 print $command, "\n"; 1536 1539 } 1537 #print "\n";1538 1540 } 1539 1541 } else { 1540 my $command = get_command_uniform_name($input_command); 1541 my @params = get_command_possible_params($input_command); 1542 print "params: ", Dumper(@params); 1542 1543 # complete dasscm parameter 1544 my $command = get_command_uniform_name($input[0]); 1545 my @params = get_command_possible_params($input[0]); 1546 if( $verbose ) { print "params: ", Dumper(@params); } 1543 1547 if( defined($params[$number_arguments-2]) && $params[$number_arguments-2] ) { 1544 1548 my $param = $params[$number_arguments-2]; 1545 print "param: $param\n"; 1546 print Dumper($param); 1547 } 1548 } 1549 if( $param eq "PATH" ) { 1550 complete_path( $input[$number_arguments-1] ); 1551 } elsif ( $param eq "REPOPATH" ) { 1552 complete_repopath( $input[$number_arguments-1] ); 1553 } else { 1554 print "param: $param\n"; 1555 print Dumper($param); 1556 } 1557 } 1558 } 1559 } 1560 1561 1562 1563 sub complete_path(@) 1564 { 1565 check_parameter( @_, 1 ); 1566 check_env(); 1567 1568 ( 1569 my $basename, 1570 my $dirname_prod, 1571 my $dirname_repo, 1572 my $filename_prod, 1573 my $filename_repo 1574 ) = get_filenames( $_[0] ); 1575 1576 my $path = $filename_prod . "*"; 1577 1578 my @files = glob( $path ); 1579 1580 # if only one result is available 1581 # and this result is a directory, 1582 # add another result entry 1583 # (otherwise complete will stop here and continue with the next parameter) 1584 if( $#files == 0 ) { 1585 my $path = $files[0]; 1586 if( -d $path ) { 1587 push( @files, $path . "/" ); 1588 } 1589 } 1590 1591 if (@files) { 1592 print join( "\n", @files ); 1593 print "\n"; 1594 } 1595 } 1596 1597 1598 1599 sub complete_repopath(@) 1600 { 1601 check_parameter( @_, 1 ); 1602 check_env(); 1603 1604 ( 1605 my $basename, 1606 my $dirname_prod, 1607 my $dirname_repo, 1608 my $filename_prod, 1609 my $filename_repo 1610 ) = get_filenames( $_[0] ); 1611 1612 my $path = $filename_repo . "*"; 1613 1614 my @files = glob( $path ); 1615 1616 # if only one result is available 1617 # and this result is a directory, 1618 # add another result entry 1619 # (otherwise complete will stop here and continue with the next parameter) 1620 if( $#files == 0 ) { 1621 my $path = $files[0]; 1622 if( -d $path ) { 1623 push( @files, $path . "/" ); 1624 } 1625 } 1626 1627 if (@files) { 1628 # remove DASSCM_REPO path again 1629 print join( "\n", map( { s|^${DASSCM_REPO}|/|; $_} @files ) ); 1630 print "\n"; 1631 } 1632 1549 1633 } 1550 1634 … … 1607 1691 # so we can test for it later on more simply 1608 1692 # 1609 1610 # $_ = $command;1611 # if (m/^help$/i) {1612 # help(@ARGV);1613 # } elsif (m/^login$/i) {1614 # $command = "login";1615 # login(@ARGV);1616 # } elsif (m/^init$/i) {1617 # $command = "init";1618 # init(@ARGV);1619 # } elsif (m/^ls$/i) {1620 # $command = "ls";1621 # ls(@ARGV);1622 # } elsif ( (m/^update$/i) || (m/^up$/i) ) {1623 # $command = "update";1624 # update(@ARGV);1625 # } elsif (m/^add$/i) {1626 # $command = "add";1627 # add(@ARGV);1628 # } elsif ( (m/^commit$/i) || (m/^checkin$/i) || (m/^ci$/i) ) {1629 # $command = "commit";1630 # commit(@ARGV);1631 # } elsif (m/^revert$/i) {1632 # $command = "revert";1633 # $return_code = revert(@ARGV);1634 # } elsif (m/^blame$/i) {1635 # $command = "blame";1636 # blame(@ARGV);1637 # } elsif (m/^diff$/i) {1638 # $command = "diff";1639 # diff(@ARGV);1640 # } elsif ( (m/^status$/i) || (m/^st$/i) ) {1641 # $command = "status";1642 # $return_code = status(@ARGV);1643 # } elsif (m/^check$/i) {1644 # $command = "check";1645 # $return_code = check();1646 # } elsif (m/^permissions$/i) {1647 # $command = "permissions";1648 # $return_code = permissions();1649 # } elsif (m/^cleanup$/i) {1650 # $command = "cleanup";1651 # cleanup();1652 # } elsif (m/^complete$/i) {1653 # $command = "complete";1654 # $return_code = complete(@ARGV);1655 1693 1656 1694 if( get_command_function( $command ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.