Changeset 2399
- Timestamp:
- 06/13/20 18:55:42 (4 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Base.pm
r2397 r2399 482 482 sub term { $_[0]->Context->Term } 483 483 sub Interractive { $_[0]->Context->Interactive } 484 sub print { shift->Context->print(@_) } 484 sub print { shift->Context->print (@_) } 485 sub printf { shift->Context->printf(@_) } 485 486 486 487 sub Top { … … 494 495 } 495 496 497 sub _parse_cmd_line { 498 my ( $self, $cmdLine ) = @_; 499 500 my ($op, $shellLine, $internalLine); 501 502 if ($cmdLine =~ /^(.*?)(?<![\\|])([\|\>])\s*([^\|].*)?$/) { 503 $internalLine = $1; 504 $op = $2; 505 $shellLine = $3; 506 } else { 507 $internalLine = $cmdLine; 508 } 509 510 return ( $op, $shellLine, shellwords($internalLine) ); 511 512 } 513 496 514 =head2 cli 497 515 … … 507 525 while (1) { 508 526 $term->Attribs->{completion_function} = sub { 509 $self->complete($_[0], shellwords(substr($_[1], 0, $_[2]))); 527 my ($Op, $Shell, @args) = $self->_parse_cmd_line(substr($_[1], 0, $_[2])); 528 $Op ||= ''; 529 my $attribs = $self->Context->Term->Attribs; 530 if ($Op eq '>') { 531 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 532 } elsif ($Op eq '|') { 533 $term->completion_matches($Shell, $attribs->{'filename_completion_function'}); 534 } else { 535 $self->complete($_[0], @args); 536 } 510 537 }; 511 538 defined (my $line = $term->readline($self->prompt)) or do { … … 515 542 $_[0]->Context->{_line} = $line; 516 543 $term->addhistory($line) if ($line =~ /\S/); 517 my $res = $self->run(shellwords($line)); 544 my ($Op, $Shell, @args) = $self->_parse_cmd_line($line); 545 my $Handle; 546 if ($Op) { 547 open($Handle, "$Op $Shell") or next; 548 $self->Context->TempOut($Handle); 549 } 550 my $res = $self->run(@args); 551 if ($Handle) { 552 $self->Context->TempOut(undef); 553 close($Handle); 554 } 518 555 $self->rollback if (!$self->Context->TransMode); 519 556 if ($res && $res eq 'EXIT') { $self->print("\n"); return } -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Context.pm
r2397 r2399 37 37 has La => ( is => 'ro' ); 38 38 has Out => ( is => 'ro' ); 39 has TempOut => ( is => 'rw' ); 39 40 has Interractive => ( is => 'rw', isa => 'Bool', default => 1 ); 40 41 … … 69 70 sub print { 70 71 my ( $self, @args ) = @_; 71 my $out = $self-> Out;72 my $out = $self->TempOut || $self->Out; 72 73 73 74 print $out @args; … … 80 81 sub printf { 81 82 my ( $self, $str, @args ) = @_; 82 my $out = $self-> Out;83 my $out = $self->TempOut || $self->Out; 83 84 84 85 printf $out $str, @args;
Note: See TracChangeset
for help on using the changeset viewer.