| 1 | package App::RepoSync::Command::Export; | ||
| 2 | use 5.10.0; | ||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use base qw( CLI::Framework::Command ); | ||
| 6 | use Cwd; | ||
| 7 | use YAML; | ||
| 8 | use App::RepoSync::Export; | ||
| 9 | |||
| 10 | sub run { | ||
| 11 | my ($self,$opts,@args) = @_; | ||
| 12 | |||
| 13 | my ($export_file,@dirs) = @args; | ||
| 14 | |||
| 15 | my $cwd = getcwd(); | ||
| 16 | |||
| 17 | $export_file ||= 'repos.yml'; | ||
| 18 | @dirs = getcwd() unless @dirs; | ||
| 19 | |||
| 20 | my @data = (); | ||
| 21 | for( @dirs ) { | ||
| 22 | say "scanning $_"; | ||
| 23 | chdir $cwd; | ||
| 24 | my @repos = App::RepoSync::Export->run( $_ ); | ||
| 25 | push @data, @repos; | ||
| 26 | } | ||
| 27 | |||
| 28 | chdir $cwd; | ||
| 29 | |||
| 30 | say "writing $export_file..."; | ||
| 31 | YAML::DumpFile( $export_file , { | ||
| 32 | version => 0.1, | ||
| 33 | repos => \@data, | ||
| 34 | }); | ||
| 35 | |||
| 36 | say "done. @{[ scalar @data ]} repositories exported."; | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | 1; |