App-BCVI
view release on metacpan or search on metacpan
When used with C<--listener>, this is the port the server process will listen
on. When used with C<--wrap-ssh> this is the port number on the remote machine
that will be forwarded back to the listener process. The default in both cases
is calculated using the user's numeric UID multiplied by 10 and added to 9.
The intent is to reduce the chance of collisions with other bcvi users.
END_POD
);
$class->register_option(
name => 'command',
alias => 'c',
arg_spec => '=s',
arg_name => '<cmnd>',
summary => 'command to send over back-channel',
description => <<'END_POD'
Use C<cmnd> as the command to send over the back-channel (default: vi).
Recognised commands are described in L<COMMANDS> below.
END_POD
);
$class->register_option(
name => 'reuse-auth',
summary => "don't generate a new auth key on listener startup",
description => <<'END_POD'
A new (random) authorisation key is generated when the listener process is
started - this will invalidate the keys in use by existing SSH sessions.
This option is for use when it is necessary to restart the listener process
without invalidating client keys.
END_POD
);
$class->register_option(
name => 'plugin-help',
arg_spec => '=s',
arg_name => '<plugin>',
dispatch_to => 'plugin_help',
summary => "display documentation for <plugin>",
description => <<'END_POD'
The --help output includes a list of installed plugins. Use this option to
read the documentation for a named plugin.
END_POD
);
$class->register_command(
name => 'vi',
description => <<'END_POD'
Invokes C<gvim> on the remote file - after translating the host+path to
an scp URI. This is the default command if no C<--command> option is
specified. If multiple filenames are supplied, the first will be opened
in gvim and you should use C<:n> to load the 'next' file.
END_POD
);
$class->register_command(
name => 'viwait',
description => <<'END_POD'
This command works exactly the same as C<vi> above, except it waits for the
editor process to exit before bcvi exits on the remote machine. This is
primarily for use with C<sudoedit>. Note: when used with C<sudoedit>, the file
will not be updated on the remote machine until you exit the editor on your
workstation.
END_POD
);
$class->register_command(
name => 'scpd',
description => <<'END_POD'
Uses C<scp> to copy the specified files or directories to the calling user's
F<~/Desktop>.`
END_POD
);
$class->add_home_bin();
$class->register_aliases(
'test -n "$(which bcvi)" && eval "$(bcvi --unpack-term)"',
'test -n "${BCVI_CONF}" && alias vi="bcvi"',
'test -n "${BCVI_CONF}" && alias suvi="EDITOR=\'bcvi -c viwait\' sudoedit"',
'test -n "${BCVI_CONF}" && alias bcp="bcvi -c scpd"',
);
$class->pod_class->init();
}
sub register_option {
my $class = shift;
my $opt = { @_ };
my $key = $opt->{name};
if(!defined $key or !length $key) {
die "Can't register option without 'name'";
}
my($package, $filename, $line) = caller();
$opt->{provider} = "$package at $filename line $line";
my $taken = $options{$key};
if($taken && !$opt->{force_override}) {
warn "option '--$key' already registered by $taken->{provider}\n";
}
if($opt->{alias}) {
foreach my $a (map { s/^-+//; $_ } split /\|/, $opt->{alias}) {
if($option_name{$a} && !$opt->{force_override}) {
if($taken = $options{$option_name{$a}}) {
warn "alias '$a' already registered for option "
. "'--$taken->{name}' by $taken->{provider}\n";
}
}
$option_name{$a} = $key;
}
}
$options{$key} = $opt;
}
sub register_command {
my $class = shift;
my $cmd = { @_ };
my $key = $cmd->{name};
( run in 1.700 second using v1.01-cache-2.11-cpan-39bf76dae61 )