mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-04 02:13:22 +00:00
Further work on config module
This commit is contained in:
parent
5fb98fc796
commit
81a79902b6
3 changed files with 104 additions and 12 deletions
|
@ -10,6 +10,8 @@ use Carp;
|
||||||
|
|
||||||
use base qw/ App::ClusterSSH::Base /;
|
use base qw/ App::ClusterSSH::Base /;
|
||||||
|
|
||||||
|
my %clusters;
|
||||||
|
my @app_specific = ( qw/ title comms method ssh rsh telnet ccon / );
|
||||||
my %default_config = (
|
my %default_config = (
|
||||||
terminal => "xterm",
|
terminal => "xterm",
|
||||||
terminal_args => "",
|
terminal_args => "",
|
||||||
|
@ -82,6 +84,8 @@ sub validate_args {
|
||||||
my @unknown_config = ();
|
my @unknown_config = ();
|
||||||
|
|
||||||
foreach my $config ( sort( keys(%args) ) ) {
|
foreach my $config ( sort( keys(%args) ) ) {
|
||||||
|
next if grep /$config/, @app_specific;
|
||||||
|
|
||||||
if ( exists $self->{$config} ) {
|
if ( exists $self->{$config} ) {
|
||||||
$self->{$config} = $args{$config};
|
$self->{$config} = $args{$config};
|
||||||
}
|
}
|
||||||
|
@ -146,8 +150,19 @@ sub parse_config_file {
|
||||||
}
|
}
|
||||||
close(CFG);
|
close(CFG);
|
||||||
|
|
||||||
|
# grab any clusters from the config before validating it
|
||||||
|
if ( $read_config{clusters} ) {
|
||||||
|
carp("TODO - deal with clusters");
|
||||||
|
$self->debug( 3, "Picked up clusters defined in $config_file" );
|
||||||
|
foreach my $cluster ( sort split / /, $read_config{clusters} ) {
|
||||||
|
delete( $read_config{$cluster} );
|
||||||
|
}
|
||||||
|
delete( $read_config{clusters} );
|
||||||
|
}
|
||||||
|
|
||||||
# tidy up entries, just in case
|
# tidy up entries, just in case
|
||||||
$read_config{terminal_font} =~ s/['"]//g if($read_config{terminal_font});
|
$read_config{terminal_font} =~ s/['"]//g
|
||||||
|
if ( $read_config{terminal_font} );
|
||||||
|
|
||||||
$self->validate_args(%read_config);
|
$self->validate_args(%read_config);
|
||||||
}
|
}
|
||||||
|
|
17
t/15config.t
17
t/15config.t
|
@ -159,4 +159,21 @@ is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||||
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
||||||
is_deeply( $config, \%expected, 'amended config is correct' );
|
is_deeply( $config, \%expected, 'amended config is correct' );
|
||||||
|
|
||||||
|
$file = "$Bin/$Script.file3";
|
||||||
|
note("using $file");
|
||||||
|
$config = App::ClusterSSH::Config->new();
|
||||||
|
%expected = %default_config;
|
||||||
|
trap {
|
||||||
|
$config = $config->parse_config_file( $file, );
|
||||||
|
};
|
||||||
|
|
||||||
|
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' );
|
||||||
|
}
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
60
t/15config.t.file3
Normal file
60
t/15config.t.file3
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# Configuration dump produced by 'cssh -u'
|
||||||
|
auto_quit=yes
|
||||||
|
clusters=duncs test fred duncs1 fred1 test1 test2 test3 test4 test5 live test dev kvm
|
||||||
|
command=
|
||||||
|
comms=ssh
|
||||||
|
console_position=
|
||||||
|
extra_cluster_file=
|
||||||
|
history_height=10
|
||||||
|
history_width=40
|
||||||
|
key_addhost=Control-Shift-plus
|
||||||
|
key_clientname=Alt-n
|
||||||
|
key_history=Alt-h
|
||||||
|
key_paste=Control-v
|
||||||
|
key_quit=Control-q
|
||||||
|
key_retilehosts=Alt-r
|
||||||
|
max_host_menu_items=30
|
||||||
|
method=ssh
|
||||||
|
mouse_paste=Button-2
|
||||||
|
rsh_args=
|
||||||
|
screen_reserve_bottom=60
|
||||||
|
screen_reserve_left=0
|
||||||
|
screen_reserve_right=0
|
||||||
|
screen_reserve_top=0
|
||||||
|
show_history=0
|
||||||
|
ssh=/usr/bin/ssh
|
||||||
|
ssh_args= -x -o ConnectTimeout=10
|
||||||
|
telnet_args=
|
||||||
|
terminal=/usr/bin/xterm
|
||||||
|
terminal_allow_send_events=-xrm '*.VT100.allowSendEvents:true'
|
||||||
|
terminal_args=
|
||||||
|
terminal_bg_style=dark
|
||||||
|
terminal_colorize=1
|
||||||
|
terminal_decoration_height=10
|
||||||
|
terminal_decoration_width=8
|
||||||
|
terminal_font=6x13
|
||||||
|
terminal_reserve_bottom=0
|
||||||
|
terminal_reserve_left=5
|
||||||
|
terminal_reserve_right=0
|
||||||
|
terminal_reserve_top=5
|
||||||
|
terminal_size=80x24
|
||||||
|
terminal_title_opt=-T
|
||||||
|
title=CSSH
|
||||||
|
unmap_on_redraw=no
|
||||||
|
use_hotkeys=yes
|
||||||
|
window_tiling=yes
|
||||||
|
window_tiling_direction=right
|
||||||
|
duncs=orion
|
||||||
|
test=macbook
|
||||||
|
fred=duncs test
|
||||||
|
duncs1=orion
|
||||||
|
test1=macbook
|
||||||
|
fred1=duncs test
|
||||||
|
test2=macbook
|
||||||
|
test3=macbook
|
||||||
|
test4=macbook
|
||||||
|
test5=macbook
|
||||||
|
live = live1 live2 live3 \
|
||||||
|
live4 live 5 live 6
|
||||||
|
test=test1 test2 test3 test4
|
||||||
|
dev=dev1 dev2 dev3 dev4
|
Loading…
Add table
Add a link
Reference in a new issue