Changeset 191
- Timestamp:
- 02/07/05 22:21:51 (4 years ago)
- Files:
-
- manage/trunk/CLI.pm (modified) (6 diffs)
- manage/trunk/manage (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
manage/trunk/CLI.pm
r190 r191 13 13 use CLI::Context; 14 14 15 $VERSION = 0. 1;15 $VERSION = 0.2; 16 16 my $BREAK = 0; 17 17 … … 124 124 my $command = shift; 125 125 my $type = ref($help); 126 my $group = shift() || ' DEFAULT';126 my $group = shift() || '100'; 127 127 128 128 if ($type eq 'ARRAY') { 129 $commands->{$ command} = [ $help->[1], $group ];129 $commands->{$help->[0]} = [ $help->[1], $group ]; 130 130 } elsif ($type eq 'HASH') { 131 131 for my $k (keys(%$help)) { … … 167 167 168 168 if (ref($cmd->{$key}) eq 'HASH' and $cmd->{$key}->{HELP}) { 169 my $group = " DEFAULT";169 my $group = "0"; 170 170 171 171 $group = $1 if $key =~ /(?:\d+\))?(?:{(.*?)})(?:\$(\*)?)?/; 172 172 $process_help->($cmd->{$key}->{HELP}, \%commands, $text, $group); 173 173 } else { 174 $commands{$text} = [ '', ' DEFAULT' ];174 $commands{$text} = [ '', '100' ]; 175 175 } 176 176 } … … 187 187 $process_help->($cmd->{ACTION}->{HELP}, \%commands, '<eol>'); 188 188 } elsif ($cmd->{ACTIONHELP}) { 189 $commands{'<eol>'} = [ $cmd->{ACTIONHELP}, ' DEFAULT' ];189 $commands{'<eol>'} = [ $cmd->{ACTIONHELP}, '100' ]; 190 190 } elsif ($cmd->{HELP}) { 191 191 $process_help->($cmd->{HELP}, \%commands, '<eol>'); 192 192 } else { 193 $commands{'<eol>'} = [ "\e[31m\e[1m(need ACTIONHELP, ACTION->HELP or HELP entry)\e[0m", ' DEFAULT' ];194 } 195 } 196 197 $commands{'<eol>'} = [ 'Execute command.', ' DEFAULT' ] if $checkpoint and not defined($commands{'<eol>'}) and defined($cmd->{ACTION});193 $commands{'<eol>'} = [ "\e[31m\e[1m(need ACTIONHELP, ACTION->HELP or HELP entry)\e[0m", '100' ]; 194 } 195 } 196 197 $commands{'<eol>'} = [ 'Execute command.', '100' ] if $checkpoint and not defined($commands{'<eol>'}) and defined($cmd->{ACTION}); 198 198 199 199 my $keywidth = 0; … … 204 204 $format->leftMargin($keywidth + 2); 205 205 for my $name (sort { 206 # Same group, do a normal compare 206 207 if ($commands{$a}->[1] eq $commands{$b}->[1]) { 207 208 if ($a =~ /^\d+$/ and $b =~ /^\d+$/) { … … 211 212 } 212 213 } else { 213 $commands{$a}->[1] cmp $commands{$b}->[1]; 214 } 215 } keys(%commands)) { 216 $help .= "\n" if defined($last_group) and $last_group ne $commands{$name}->[1]; 214 if ($commands{$a}->[1] =~ /^\d+\)/ and $commands{$b}->[1] =~ /^\d+\)/) { 215 my ($lhs, $rhs); 216 $commands{$a}->[1] =~ /^(\d+)\)/; $lhs = $1; 217 $commands{$b}->[1] =~ /^(\d+)\)/; $rhs = $1; 218 $lhs <=> $rhs; 219 } else { 220 $commands{$a}->[1] cmp $commands{$b}->[1]; 221 } 222 } 223 } keys(%commands)) { 224 if ((defined($last_group) and $last_group ne $commands{$name}->[1]) or not defined($last_group)) { 225 my $title = $commands{$name}->[1]; 226 227 $title =~ s/^\d+(?:\)|$)//; 228 if ($title) { 229 $help .= "\e[36m$title\e[0m\n" ; 230 } elsif (defined($last_group)) { 231 $help .= "\n"; 232 } 233 } 217 234 if ($commands{$name}) { 218 235 $help .= sprintf(" \e[1m%-${keywidth}s\e[0m ", $name) . substr($format->format($commands{$name}->[0]), $keywidth + 2); manage/trunk/manage
r189 r191 297 297 entered exactly as shown. Words enclosed in $C{bold}< >$C{normal} are user defined. 298 298 ", 299 '{ zMANAGE}set' => {299 '{9999}set' => { 300 300 HELP => 'Query/modify settings.', 301 301 '$[\w.-]+' => { … … 368 368 }, 369 369 }, 370 '{ zMANAGE}history' => {370 '{9999}history' => { 371 371 clear => { 372 372 ACTION => sub { … … 385 385 HELP => "Display command line history.", 386 386 }, 387 '{ zMANAGE}quit|exit' => {387 '{9999}quit|exit' => { 388 388 HELP => [ 'exit', 'Exit.' ], 389 389 ACTION => sub { exit; },
