Add in auto_close functionality

Set whether terminal windows close after given numnber of seconds or wait until input given into terminal windows
This commit is contained in:
Duncan Ferguson 2011-11-24 21:48:35 +00:00
parent 23483ce362
commit 2b7ec74e6a
4 changed files with 28 additions and 5 deletions

View file

@ -132,6 +132,10 @@ Run the command in each session, i.e. C<-a 'vi /etc/hosts'> to drop straight
into a vi session. NOTE: not all communications methods support this (ssh
and rsh should, telnet and console will not).
=item --autoclose,-A <seconds>
Number of seconds to wait before closing finished terminal windows.
=item --autoquit,-q|--no-autoquit,-Q
Enable|Disable automatically quiting after the last client window has closed
@ -377,6 +381,12 @@ should be written as
Setting to anything other than C<yes> does not perform window tiling (see also -G).
=item auto_close = 5
Close terminal window after this many seconds. If set to 0 will instead wait
on input from the user in each window before closing. Can be overridden
by C<-K> on the command line
=item auto_quit = yes
Automatically quit after the last client window closes. Set to anything

View file

@ -108,6 +108,7 @@ my @options_spec = (
'port|p=i',
'autoquit|q',
'no-autoquit|Q',
'autoclose|K=i',
'history|s',
'term-args|t=s',
'title|T=s',
@ -1865,6 +1866,14 @@ sub run {
= !$self->config->{use_all_a_records} || 0;
}
if ( $options{action} ) {
$self->config->{command} = $options{action} ;
}
$self->config->{auto_quit} = "yes" if $options{autoquit};
$self->config->{auto_quit} = "no" if $options{'no-autoquit'};
$self->config->{auto_close} = $options{autoclose} if $options{'autoclose'};
$self->config->dump() if ( $options{'output-config'} );
$self->evaluate_commands() if ( $options{evaluate} );
@ -2002,6 +2011,8 @@ the code until this time.
=item helper
=item cluster
=item create_menubar
=item create_windows

View file

@ -25,6 +25,9 @@ sub script {
my $comms = $config->{comms};
my $comms_args = $config->{$comms.'_args'};
my $command = $config->{command};
my $autoclose = $config->{auto_close};
my $postcommand = $autoclose ? "echo Press RETURN to continue; read IGNORE" : "sleep $autoclose";
# # P = pipe file
# # s = server
@ -116,7 +119,7 @@ sub script {
\$command .= "\$svr";
}
}
\$command .= " $command || sleep 5";
\$command .= " $command ; $postcommand";
warn("Running:\$command\\n"); # for debug purposes
exec(\$command);
HERE

View file

@ -39,6 +39,7 @@ Readonly::Hash my %default_config => {
key_paste => "Control-v",
mouse_paste => "Button-2",
auto_quit => "yes",
auto_close => 5,
window_tiling => "yes",
window_tiling_direction => "right",
console_position => "",
@ -185,10 +186,7 @@ is( $trap->leaveby, 'return', 'returned ok' );
is( $trap->die, undef, 'returned ok' );
isa_ok( $config, "App::ClusterSSH::Config" );
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
{
local $TODO = "deal with cluster definitions in config file";
is( $trap->stderr, q{}, 'Expecting no STDERR' );
}
is( $trap->stderr, q{}, 'Expecting no STDERR' );
note('find_binary tests');
my $path;
@ -437,6 +435,7 @@ trap {
};
my $expected = <<'EOF';
# Configuration dump produced by "cssh -u"
auto_close=5
auto_quit=yes
console_position=
debug=0