App-BCVI
view release on metacpan or search on metacpan
sub run {
App::BCVI->base_init();
App::BCVI->load_plugins();
App::BCVI->base_class()->process_command_line(@_);
exit;
}
sub version { return $App::BCVI::VERSION; }
sub base_class { return $class_map{base}; }
sub client_class { return $class_map{client}; }
sub server_class { return $class_map{server}; }
sub pod_class { return $class_map{pod}; }
sub map_class { $class_map{$_[1]} = $_[2]; }
sub sock { shift->{sock}; }
sub installable_files { return @installables; }
sub message_from_code { $response_message{$_[1]}; }
sub base_init {
my($class) = @_;
$class->register_option(
name => 'help',
alias => '?',
dispatch_to => 'show_help',
summary => 'detailed help message',
description => <<'END_POD'
Display this documentation.
END_POD
);
$class->register_option(
name => 'debug',
alias => 'd',
summary => 'turn on debugging',
description => <<'END_POD'
Turn on debugging messages.
END_POD
);
$class->register_option(
name => 'add-aliases',
dispatch_to => 'add_aliases',
summary => 'install bcvi into shell startup files',
description => <<'END_POD'
Edit the bash startup script to add (or update) the required command aliases
for bcvi.
END_POD
);
$class->register_option(
name => 'listener',
alias => 'l',
dispatch_to => 'start_listener',
summary => 'start in listener mode',
description => <<'END_POD'
Start a background listener process. Also generates a new authentication key.
END_POD
);
$class->register_option(
name => 'install',
arg_name => '<hosts>',
dispatch_to => 'install_to_hosts',
summary => 'copy bcvi to named hosts and install aliases',
description => <<'END_POD'
Copy the C<bcvi> script to the C<$HOME/bin> directory on the specified host
and then remotely invoke it with the C<--add-aliases> option.
END_POD
);
$class->register_option(
name => 'unpack-term',
dispatch_to => 'unpack_term',
summary => 'unpack the overloaded TERM variable',
description => <<'END_POD'
This option is intended for use from a F<.profile> script. It outputs a
snippet of shell script to be passed to C<eval> in the calling shell.
END_POD
);
$class->register_option(
name => 'wrap-ssh',
alias => 's',
dispatch_to => 'wrap_ssh',
summary => 'pass all args after -- to ssh',
description => <<'END_POD'
A wrapper around invoking ssh to connect to a specified host. Ensures the
environment is set up to pass the authentication key and other data to the
C<bcvi> client on the remote server.
END_POD
);
$class->register_option(
name => 'version',
alias => 'v',
dispatch_to => 'show_versions',
summary => 'display bcvi version number',
description => <<'END_POD'
When invoking a command use this option to indicate that the arguments are not
filenames and the translation of relative pathnames to absolute should be
skipped.
END_POD
);
$class->register_option(
name => 'no-path-xlate',
alias => 'n',
summary => 'skip translation of args from relative to absolute',
description => <<'END_POD'
Displays the version number of the bcvi client and if applicable, of the
listener process.
END_POD
);
$class->register_option(
name => 'port',
$parser->parse_from_filehandle($pod_fh, $pager);
}
}
sub pager {
my @commands = $ENV{PAGER} ? ( $ENV{PAGER} ) : qw(pager less more);
foreach my $file (@commands) {
foreach my $dir ( File::Spec->path() ) {
my $exe_path = File::Spec->catfile($dir, $file);
if(-x $exe_path) {
open my $fh, '|-', $exe_path or next;
return $fh;
}
}
}
return \*STDOUT;
}
1;
__DATA__
=head1 NAME
bcvi - Back-channel vi, a shell utility to proxy commands back over ssh
=head1 SYNOPSIS
bcvi [options] [<files>]
Options:
=for BCVI_OPTIONS_SUMMARY
=head1 DESCRIPTION
This utility works with SSH to allow commands issued on the SSH server host to
be 'proxied' back to the SSH client host. For example:
=over 4
=item *
user F<sally> establishes an SSH connection from her workstation to a server
named F<pluto> and runs the command C<bcvi .bashrc>
=item *
bcvi tunnels the details back to sally's workstation which then invokes the
command C<gvim scp://pluto//home/sally/.bashrc>
=item *
the result is that sally gets a responsive GUI editor running on her local
machine, but editing a file on the remote machine
=back
See C<< perldoc App::BCVI >> for more examples and background information.
=head1 OPTIONS
=for BCVI_OPTIONS
=head1 COMMANDS
The following commands can be passed back to the listener process.
=for BCVI_COMMANDS
=head1 USING BCVI
You'll need to start a listener process on your workstation (perhaps from
your window manager session startup).
bcvi -l &
To install the bcvi client to a remote machine:
bcvi --install <hostname>
To ssh to a server with tunnelling enabled:
bcvi --wrap-ssh -- hostname
To enable bcvi on all ssh connections:
alias ssh="bcvi --wrap-ssh --"
On a target server, you'll need to unpack the overloaded TERM variable:
test -n "$(which bcvi)" && eval "$(bcvi --unpack-term)"
To use vi over the back-channel:
bcvi filename
The installation to a remote server should set up aliases, e.g.:
test -n "${BCVI_CONF}" && alias vi="bcvi"
test -n "${BCVI_CONF}" && alias bcp="bcvi -c scpd"
=head1 PLUGINS
=for BCVI_PLUGINS
=head1 COPYRIGHT
Copyright 2007-2012 Grant McLean E<lt>grantm@cpan.orgE<gt>
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
( run in 0.776 second using v1.01-cache-2.11-cpan-f56aa216473 )