App::EditorTools::Command::RenamePackageFromPath - Rename the Package Based on the Path of the File


App-EditorTools documentation Contained in the App-EditorTools distribution.

Index


Code Index:

NAME

Top

App::EditorTools::Command::RenamePackageFromPath - Rename the Package Based on the Path of the File

DESCRIPTION

Top

See App::EditorTools for documentation.

AUTHOR

Top

Mark Grimes, <mgrimes@cpan.org>

COPYRIGHT AND LICENSE

Top


App-EditorTools documentation Contained in the App-EditorTools distribution.

package App::EditorTools::Command::RenamePackageFromPath;

use strict;
use warnings;

use App::EditorTools -command;

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};
    return 1;
}

sub execute {
    my ( $self, $opt, $arg ) = @_;

    my $doc_as_str = eval { local $/ = undef; <STDIN> };

    require PPIx::EditorTools::RenamePackageFromPath;
    print PPIx::EditorTools::RenamePackageFromPath->new->rename(
        code     => $doc_as_str,
        filename => $opt->{filename} )->code;
    return;
}

1;