| 1 | package App::GitGot::Command::move; | ||||||||||
| 2 | 16 | our $AUTHORITY = 'cpan:GENEHACK'; | |||||||||
| 3 | 16 | $App::GitGot::Command::move::VERSION = '1.339'; | |||||||||
| 4 | # ABSTRACT: move repo to new location | ||||||||||
| 5 | 16 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 16 | ▶ | use Cwd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 16 | ▶ | use File::Copy::Recursive qw/ dirmove /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 16 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 16 | ▶ | use App::GitGot -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 16 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 16 | extends 'App::GitGot::Command'; | |||||||||
| 15 | 16 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 43 | ▶ | sub command_names { qw/ move mv / } | ||||||||
|
Subroutine
command_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub options { | ||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 20 | 1 | my( $class , $app ) = @_; | |||||||||
| 21 | return ( | ||||||||||
| 22 | 1 | [ 'destination=s' => 'FIXME' => { required => 1 } ] , | |||||||||
| 23 | ); | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | sub _execute { | ||||||||
|
Subroutine
_execute: called CC=5 SCAR=16.4
| |||||||||||
| 27 | 1 | my( $self, $opt, $args ) = @_; | |||||||||
| 28 | |||||||||||
| 29 | 1 | my @repos = $self->active_repos; | |||||||||
| 30 | |||||||||||
| 31 | 1 | my $dest = $self->opt->destination; | |||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | path($dest)->mkpath if @repos > 1; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 1 | for my $repo ( @repos ) { | |||||||||
| 36 | 1 | ▶ | my $target_dir = -d $dest | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | ? path($dest)->child( path($repo->path)->basename ) | ||||||||||
| 38 | : $dest; | ||||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | dirmove( $repo->path => $target_dir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | or die "couldn't move ", $repo->name, " to '$target_dir': $!"; | ||||||||||
| 42 | |||||||||||
| 43 | 1 | $repo->{path} = "$target_dir"; | |||||||||
| 44 | 1 | $self->write_config; | |||||||||
| 45 | |||||||||||
| 46 | 1 | say sprintf '%s moved to %s', $repo->name, $target_dir; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 16 | 1; | |||||||||
| 51 | |||||||||||
| 52 | ## FIXME docs | ||||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||