Move some post-processing option handling into the getopt module

This commit is contained in:
Duncan Ferguson 2014-06-22 14:42:21 +01:00
parent e6ed822a43
commit 2f9779d8f5
2 changed files with 12 additions and 23 deletions

View file

@ -1898,17 +1898,6 @@ sub run {
$self->debug( 2, "VERSION: $VERSION" );
if ( $options{use_all_a_records} ) {
$self->config->{use_all_a_records}
= !$self->config->{use_all_a_records} || 0;
}
if ( $options{action} ) {
$self->config->{command} = $options{action};
}
$self->config->{unique_servers} = 1 if $options{'unique-servers'};
$self->config->{auto_quit} = "yes" if $options{autoquit};
$self->config->{auto_quit} = "no" if $options{'no-autoquit'};
$self->config->{auto_close} = $options{autoclose}
@ -1917,21 +1906,18 @@ sub run {
$self->config->{window_tiling} = "yes" if $options{tile};
$self->config->{window_tiling} = "no" if $options{'no-tile'};
$self->config->{user} = $options{username} if ( $options{username} );
$self->config->{port} = $options{port} if ( $options{port} );
$self->config->{show_history} = 1 if $options{'show-history'};
$self->config->{ssh_args} = $options{options} if ( $options{options} );
$self->config->{terminal_font} = $options{font} if ( $options{font} );
$self->config->{terminal_args} = $options{'term-args'}
if ( $options{'term-args'} );
if ( $self->config->{terminal_args} =~ /-class (\w+)/ ) {
$self->config->{terminal_allow_send_events}
= "-xrm '$1.VT100.allowSendEvents:true'";
}
$self->config->dump() if ( $options{'output-config'} );
$self->config->dump() if ( $self->options->output_config);
$self->evaluate_commands() if ( $options{evaluate} );

View file

@ -275,20 +275,23 @@ sub getopts {
$self->parent->config->load_configs( $self->config_file );
if($self->{title}) {
$self->parent->config->{title} = $self->title;
$self->debug(2, "Title: " . $self->title );
}
if ( $self->use_all_a_records ) {
$self->parent->config->{use_all_a_records}
= !$self->parent->config->{use_all_a_records} || 0;
}
if ( $self->action ) {
$self->parent->config->{command} = $self->action;
if ( $self->unique_servers ) {
$self->parent->config->{unique_servers} = ! $self->parent->config->{unique_servers} || 0;
}
$self->parent->config->{title} = $self->title if($self->title);
$self->parent->config->{command} = $self->action if ( $self->action );
$self->parent->config->{user} = $self->username if ($self->username);
$self->parent->config->{port} = $self->port if ($self->port);
$self->parent->config->{terminal_font} = $self->font if ($self->font);
$self->parent->config->{terminal_args} = $self->term_args if ($self->term_args);
return $self;
}