App-EditorTools
view release on metacpan or search on metacpan
lib/App/EditorTools/Command/InstallEmacs.pm view on Meta::CPAN
sub opt_spec {
return (
[ "local|l", "Install the emacs script for the user (~/.emacs.d/)" ],
[ "dest|d=s", "Full path to install the script" ],
[ "print|p", "Print the script to STDOUT" ],
[ "dryrun|n", "Print where the script would be installed" ],
## [ "global|g", "Install the script globally (/usr/share/)" ],
);
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
$self->_confirm_one_opt($opt)
or $self->usage_error(
"Options --local, --global, --dest and --print cannot be combined");
if ( !$opt->{dest} ) {
if ( $opt->{global} ) {
$self->usage_error("--global flag is not implemented");
} elsif ( !$opt->{print} ) {
lib/App/EditorTools/Command/InstallVim.pm view on Meta::CPAN
sub opt_spec {
return (
[ "local|l", "Install the vim script local for the user (~/.vim/)" ],
[ "dest|d=s", "Full path to install the vim script" ],
[ "print|p", "Print the vim script to STDOUT" ],
[ "dryrun|n", "Print where the vim script would be installed" ],
## [ "global|g", "Install the vim script globally (/usr/share/vim)" ],
);
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
$self->_confirm_one_opt($opt)
or $self->usage_error(
"Options --local, --global, --dest and --print cannot be combined");
if ( !$opt->{dest} ) {
if ( $opt->{global} ) {
$self->usage_error("--global flag is not implemented");
# $opt->{dest} = File::Spec->catfile( $self->_get_vimruntime,
lib/App/EditorTools/Command/IntroduceTemporaryVariable.pm view on Meta::CPAN
our $VERSION = '1.00';
sub opt_spec {
return (
[ "start_location|s=s", "The line,column of the start" ],
[ "end_location|e=s", "The line,column of the end" ],
[ "varname|v=s", "The new variable name" ],
);
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
$self->usage_error("start_location is required")
unless $opt->{start_location};
$self->usage_error("end_location is required") unless $opt->{end_location};
$opt->{start} = [ grep {/\d+/} split /,/, $opt->{start_location} ];
$opt->{end} = [ grep {/\d+/} split /,/, $opt->{end_location} ];
$self->usage_error("start_location must be <Int>,<Int>")
lib/App/EditorTools/Command/RenamePackage.pm view on Meta::CPAN
use Path::Class;
use App::EditorTools -command;
our $VERSION = '1.00';
sub opt_spec {
return ( [ "name|n=s", "The new name of the package", ] );
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
$self->usage_error("Name is required") unless $opt->{name};
return 1;
}
sub execute {
my ( $self, $opt, $arg ) = @_;
my $doc_as_str = eval { local $/ = undef; <STDIN> };
lib/App/EditorTools/Command/RenamePackageFromPath.pm view on Meta::CPAN
use Path::Class;
use App::EditorTools -command;
our $VERSION = '1.00';
sub opt_spec {
return ( [ "filename|f=s", "The filename and path of the package", ] );
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
$self->usage_error("Filename is required") unless $opt->{filename};
# If we are dealing with a real file, see if we can clean up the
# path. This let's us work on files under a symlink
# (ie, M/ -> lib/App/Model), but rename them correctly.
if( -f $opt->{filename} ){
my $real_name = file( $opt->{filename} )->resolve;
$opt->{filename} = $real_name if defined $real_name;
}
lib/App/EditorTools/Command/RenameVariable.pm view on Meta::CPAN
our $VERSION = '1.00';
sub opt_spec {
return (
[ "line|l=s", "Line number of the start of variable to replace", ],
[ "column|c=s", "Column number of the start of variable to replace", ],
[ "replacement|r=s", "The new variable name (without sigil)", ],
);
}
sub validate_args {
my ( $self, $opt, $args ) = @_;
for (qw(line column replacement)) {
$self->usage_error("Arg $_ is required") unless $opt->{$_};
}
return 1;
}
sub execute {
my ( $self, $opt, $arg ) = @_;
( run in 0.588 second using v1.01-cache-2.11-cpan-a5abf4f5562 )