App-ClusterSSH

 view release on metacpan or  search on metacpan

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

            $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(
        spec     => 'cols|x=i',
        arg_desc => 'cols',
        help     => $self->loc('Number of columns'),
    );
    $self->add_option(
        spec     => 'rows|y=i',
        arg_desc => 'rows',
        help     => $self->loc('Number of rows'),
    );

    $self->add_option(
        spec => 'fillscreen',
        help => $self->loc(
            'Resize terminal windows to fill the whole available screen'),
    );

    return $self;
}

# For options common to ssh sessions
sub add_common_ssh_options {
    my ($self) = @_;

    $self->add_option(
        spec => 'options|o=s',
        help => $self->loc(
            'Specify arguments to be passed to ssh when making the connection.  B<NOTE:> options for ssh should normally be put into the ssh configuration file; see C<ssh_config> and F<$HOME/.ssh/config> for more details.'
        ),
        default => '-x -o ConnectTimeout=10',
    );

    return $self;
}

# For options that work in ssh, rsh type consoles, but not telnet or console
sub add_common_session_options {
    my ($self) = @_;

    $self->add_option(
        spec     => 'username|l=s',
        arg_desc => 'username',
        help     => $self->loc(
            'Specify the default username to use for connections (if different from the currently logged in user).  B<NOTE:> will be overridden by <user>@<host>.'
        ),
    );
    $self->add_option(
        spec     => 'action|a=s',
        arg_desc => 'command',
        help     => $self->loc(
            "Run the command in each session, e.g. C<-a 'vi /etc/hosts'> to drop straight into a vi session."
        ),
    );

    return $self;
}

sub getopts {
    my ($self) = @_;
    my $options = {};

    pod2usage( -verbose => 1 )
        if ( !GetOptions( $options, keys( %{ $self->{command_options} } ) ) );
    pod2usage( -verbose => 0 ) if ( $options->{'?'} || $options->{usage} );
    pod2usage( -verbose => 1 ) if ( $options->{'h'} || $options->{help} );
    pod2usage( -verbose => 2 ) if ( $options->{H}   || $options->{man} );

    # record what was given on the command line in case this
    # object is ever dumped out
    $self->{options_parsed} = $options;

    if ( $options->{'generate-pod'} ) {
        $self->_generate_pod;
        $self->exit;
    }

    if ( $options->{version} ) {
        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/;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.758 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )