App-ClusterSSH

 view release on metacpan or  search on metacpan

lib/App/ClusterSSH/Getopt.pm  view on Meta::CPAN

    );
    $self->add_option(
        spec => 'man|H',
        help => $self->loc("Show full help text (the man page) and exit"),
        no_accessor => 1,
    );
    $self->add_option(
        spec => 'debug:+',
        help => $self->loc(
            "Enable debugging.  Either a level can be provided or the option can be repeated multiple times.  Maximum level is 9."
        ),
        default => 0,
    );
    $self->add_option(
        spec        => 'generate-pod',
        no_accessor => 1,
        hidden      => 1,
    );
    $self->add_option(
        spec     => 'autoclose|K=i',
        arg_desc => 'seconds',
        help     => $self->loc(
            'Number of seconds to wait before closing finished terminal windows.'
        ),
    );
    $self->add_option(
        spec => 'autoquit|q',
        help => $self->loc(
            'Toggle automatically quiting after the last client window has closed (overriding the config file).'
        ),
    );
    $self->add_option(
        spec     => 'evaluate|e=s',
        arg_desc => '[user@]<host>[:port]',
        help     => $self->loc(
            'Display and evaluate the terminal and connection arguments to display any potential errors.  The <hostname> is required to aid the evaluation.'
        ),
    );
    $self->add_option(
        spec     => 'config-file|C=s',
        arg_desc => 'filename',
        help     => $self->loc(
            'Use supplied file as additional configuration file (see also L</"FILES">).'
        ),
    );
    $self->add_option(
        spec     => 'cluster-file|c=s',
        arg_desc => 'filename',
        help     => $self->loc(
            'Use supplied file as additional cluster file (see also L</"FILES">).'
        ),
    );
    $self->add_option(
        spec     => 'tag-file|r=s',
        arg_desc => 'filename',
        help     => $self->loc(
            'Use supplied file as additional tag file (see also L</"FILES">)'
        ),
    );
    $self->add_option(
        spec     => 'font|f=s',
        arg_desc => 'font',
        help     => $self->loc(
            'Specify the font to use in the terminal windows. Use standard X font notation such as "5x8".'
        ),
    );
    $self->add_option(
        spec => 'list|L:s',
        help => $self->loc(
            'List available cluster tags. Tag is optional.  If a tag is provided then hosts for that tag are listed.  NOTE: format of output changes when using "--quiet" or "-Q" option.'
        ),
        arg_desc     => 'tag',
        arg_optional => 1,
    );
    $self->add_option(
        spec => 'dump-config|d',
        help => $self->loc(
            'Dump the current configuration in the same format used by the F<$HOME/.clusterssh/config> file.'
        ),
    );
    $self->add_option(
        spec     => 'port|p=i',
        arg_desc => 'port',
        help     => $self->loc('Specify an alternate port for connections.'),
    );
    $self->add_option(
        spec => 'show-history|s',
        help => $self->loc('Show history within console window.'),
    );
    $self->add_option(
        spec => 'tile|g',
        help =>
            $self->loc('Toggle window tiling (overriding the config file).'),
    );
    $self->add_option(
        spec => 'term-args|t=s',
        help => $self->loc(
            'Specify arguments to be passed to terminals being used.'),
    );
    $self->add_option(
        spec     => 'title|T=s',
        arg_desc => 'title',
        help     => $self->loc(
            'Specify the initial part of the title used in the console and client windows.'
        ),
    );
    $self->add_option(
        spec => 'unique-servers|u',
        help => $self->loc(
            'Toggle connecting to each host only once when a hostname has been specified multiple times.'
        ),
    );
    $self->add_option(
        spec => 'use-all-a-records|A',
        help => $self->loc(
            'If a hostname resolves to multiple IP addresses, toggle whether or not to connect to all of them, or just the first one (see also config file entry).'
        ),
    );
    $self->add_option(
        spec => 'quiet|Q',
        help =>
            $self->loc('Do not output extra text when using some options'),
    );
    $self->add_option(

lib/App/ClusterSSH/Getopt.pm  view on Meta::CPAN

        print 'Version: ', $self->parent->VERSION, $/;
        $self->exit;
    }

    $options->{debug} ||= 0;
    $options->{debug} = 9 if ( $options->{debug} && $options->{debug} > 9 );

    # Now all options are set to the correct values, generate accessor methods
    foreach my $option ( sort keys( %{ $self->{command_options} } ) ) {

        # skip some accessors as they are already defined elsewhere
        next if $option =~ m/^(debug)\W/;

        my $accessor = $self->{command_options}->{$option}->{accessor};

        my $default = $self->{command_options}->{$option}->{default};

        if ( my $acc = $accessor ) {
            $accessor =~ s/-/_/g;
            no strict 'refs';

          # hide warnings when getopts is run multiple times, esp. for testing
            no warnings 'redefine';
            *$accessor = sub {
                return defined $options->{$acc} ? $options->{$acc} : $default;

    #                      defined $options->{$acc} ? $options->{$acc}
    #                    : defined $self->{command_options}->{$acc}->{default}
    #                    ? $self->{command_options}->{$acc}->{default}
    #                    : undef;
            };
            my $accessor_default = $accessor . '_default';
            *$accessor_default = sub { return $default; };
        }
    }

    $self->set_debug_level( $options->{debug} );

    $self->parent->config->load_configs( $self->config_file );

    if ( $self->use_all_a_records ) {
        $self->parent->config->{use_all_a_records}
            = !$self->parent->config->{use_all_a_records} || 0;
    }

    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->{port}  = $self->port  if ( $self->port );

    # note, need to check if these actions can be performed as they are
    # not common acorss all communiction methods
    $self->parent->config->{command} = $self->action
        if ( $self->can('action') && $self->action );
    $self->parent->config->{user} = $self->username
        if ( $self->can('username') && $self->username );

    $self->parent->config->{terminal_font} = $self->font if ( $self->font );
    $self->parent->config->{terminal_args} = $self->term_args
        if ( $self->term_args );

    $self->parent->config->{show_history} = 1 if ( $self->show_history );

    $self->parent->config->{auto_close} = $self->autoclose
        if ( $self->autoclose );

    if ( $self->autoquit ) {
        $self->parent->config->{auto_quit}
            = !$self->parent->config->{auto_quit} || 0;
    }

    if ( $self->tile ) {
        $self->parent->config->{window_tiling}
            = !$self->parent->config->{window_tiling} || 0;
    }

    if ( $self->rows ) {
        $self->parent->config->{rows} = $self->rows;
    }
    if ( $self->cols ) {
        $self->parent->config->{cols} = $self->cols;
    }
    $self->parent->config->{fillscreen} = "yes"
        if ( $self->fillscreen );
    return $self;
}

sub output {
    my (@text) = @_;

    confess if ( exists $text[1] && !$text[1] );
    print @text, $/, $/;
}

# generate valid POD from all the options and send to STDOUT
# so build process can create pod files for the distribution
sub _generate_pod {
    my ($self) = @_;

    output $/ , "=pod";
    output '=head1 ',    $self->loc('NAME');
    output "$Script - ", $self->loc("Cluster administration tool");
    output '=head1 ',    $self->loc('VERSION');
    output $self->loc( "This documentation is for version: [_1]",
        $self->parent->VERSION );
    output '=head1 ', $self->loc('SYNOPSIS');

    # build the synopsis
    print "$Script ";
    foreach my $longopt ( sort keys( %{ $self->{command_options} } ) ) {
        next if ( $self->{command_options}->{$longopt}->{hidden} );

        print '['
            . (    $self->{command_options}->{$longopt}->{option_short}
                || $self->{command_options}->{$longopt}->{option_long} )
            . '] ';
    }
    print $/, $/;

lib/App/ClusterSSH/Getopt.pm  view on Meta::CPAN

    output '=item menu_send_autotearoff = 0';
    output $self->loc(
        q{When set to non-0 will automatically tear-off the host or send menu at program start}
    );

    output '=item mouse_paste = Button-2 (middle mouse button)';
    output $self->loc(
        q{Default key sequence to paste text into the console window using the mouse.  See [_1] for more information.},
        'L<KEY SHORTCUTS>'
    );

    output '=item rsh = /path/to/rsh';
    output '=item ssh = /path/to/ssh';
    output '=item telnet = /path/to/telnet';
    output $self->loc(
        q{Set the path to the specific binary to use for the communication method, else uses the first match found in [_1]},
        'C<$PATH>'
    );

    output '=item rsh_args = <blank>';
    output '=item ssh_args = "-x -o ConnectTimeout=10"';
    output '=item telnet_args = <blank>';
    output $self->loc(
        q{Sets any arguments to be used with the communication method (defaults to ssh arguments).

B<NOTE:> The given defaults are based on OpenSSH, not commercial ssh software.

B<NOTE:> Any "generic" change to the method (e.g., specifying the ssh port to use) should be done in the medium's own config file (see [_1] and [_2]).},
        'C<ssh_config>', 'F<$HOME/.ssh/config>'
    );

    output '=item screen_reserve_top = 0';
    output '=item screen_reserve_bottom = 60';
    output '=item screen_reserve_left = 0';
    output '=item screen_reserve_right = 0';
    output $self->loc(
        q{Number of pixels from the screen's side to reserve when calculating screen geometry for tiling.  Setting this to something like 50 will help keep cssh from positioning windows over your window manager's menu bar if it draws one at that side...
    );

    output '=item terminal = /path/to/xterm';
    output $self->loc(q{Path to the X-Windows terminal used for the client.});

    output '=item terminal_args = <blank>';
    output $self->loc(
        q{Arguments to use when opening terminal windows.  Otherwise takes defaults from [_1] or [_2] file.},
        'F<$HOME/.Xdefaults>', 'F<$HOME/.Xresources>'
    );

    output '=item terminal_chdir = 0';
    output $self->loc(
        q{When non-0, set the working directory for each terminal as per '[_1]'},
        'L<terminal_chdir_path>'
    );

    output '=item terminal_chdir_path = $HOME/.clusterssh/work/%s';
    output $self->loc(
        q{Path to use as working directory for each terminal when '[_1]' is enabled.  The path provided is passed through the macro parser (see the section above on '[_2]'.},
        'L<terminal_chdir>', 'L<macros_enabled>',
    );

    output '=item terminal_font = 6x13';
    output $self->loc(
        q{Font to use in the terminal windows.  Use standard X font notation.}
    );

    output '=item terminal_reserve_top = 5';
    output '=item terminal_reserve_bottom = 0';
    output '=item terminal_reserve_left = 5';
    output '=item terminal_reserve_right = 0';
    output $self->loc(
        q{Number of pixels from the terminal's side to reserve when calculating screen geometry for tiling.  Setting these will help keep cssh from positioning windows over your scroll and title bars or otherwise overlapping the windows too much.}
    );

    output '=item terminal_colorize = 1';
    output $self->loc(
        q{If set to 1 (the default), then "-bg" and "-fg" arguments will be added to the terminal invocation command-line.  The terminal will be colored in a pseudo-random way based on the host name; while the color of a terminal is not easily predic...
    );

    output '=item terminal_bg_style = dark';
    output $self->loc(
        q{If set to [_1], the terminal background will be set to black and the foreground to the pseudo-random color.  If set to [_2], then the foreground will be black and the background the pseudo-random color.  If terminal_colorize is [_3], then t...
        'C<dark>', 'C<light>', 'C<zero>'
    );

    output '=item terminal_size = 80x24';
    output $self->loc(
        q{Initial size of terminals to use. NOTE: the number of lines (24) will be decreased when resizing terminals for tiling, not the number of characters (80).}
    );

    output '=item terminal_title_opt = -T';
    output $self->loc(
        q{Option used with [_1] to set the title of the window},
        'C<terminal>' );

    output
        q{=item terminal_allow_send_events = -xrm '*.VT100.allowSendEvents:true'};
    output $self->loc(
        q{Option required by the terminal to allow XSendEvents to be received}
    );

    output '=item title = cssh';
    output $self->loc(
        q{Title of windows to use for both the console and terminals.});

    output '=item unmap_on_redraw = no';
    output $self->loc(
        q{Tell Tk to use the UnmapWindow request before redrawing terminal windows.  This defaults to "no" as it causes some problems with the FVWM window manager.  If you are experiencing problems with redraws, you can set it to "yes" to allow the w...
    );

    output '=item use_all_a_records = 0';
    output $self->loc(
        q{If a hostname resolves to multiple IP addresses, set to [_1] to connect to all of them, not just the first one found.  See also [_2]},
        'C<1>', 'C<--use-all-a-records>}'
    );

    output '=item use_hotkeys = 1';
    output $self->loc( q{Setting to [_1] will disable all hotkeys.}, 'C<0>' );

    output '=item use_natural_sort = 0';
    output $self->loc(
        q{Windows will normally sort in alphabetical order, i.e.: host1, host11, host2.  Setting to this [_1] will change the sort order, i.e.: host1, host2, host11. NOTE: You must have the perl module [_2] installed.},
        'C<1>', 'L<Sort::Naturally>'
    );



( run in 1.101 second using v1.01-cache-2.11-cpan-97f6503c9c8 )