1package Prophet::CLI::Command::Mirror; 2{ 3 $Prophet::CLI::Command::Mirror::VERSION = '0.751'; 4} 5use Any::Moose; 6use Params::Validate qw/:all/; 7 8extends 'Prophet::CLI::Command'; 9with 'Prophet::CLI::MirrorCommand'; 10 11has source => ( isa => 'Prophet::Replica', is => 'rw'); 12has target => ( isa => 'Prophet::Replica', is => 'rw'); 13 14sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(), f => 'force' } 15 16sub usage_msg { 17 my $self = shift; 18 my $cmd = $self->cli->get_script_name; 19 20 return <<"END_USAGE"; 21usage: ${cmd}mirror --from <url> 22END_USAGE 23} 24 25sub run { 26 my $self = shift; 27 Prophet::CLI->end_pager(); 28 29 $self->print_usage if $self->has_arg('h'); 30 31 $self->validate_args(); 32 33 my $source = Prophet::Replica->get_handle( 34 url => $self->arg('from'), 35 app_handle => $self->app_handle, 36 ); 37 unless ( $source->replica_exists ) { 38 print 39 "The source replica '@{[$source->url]}' doesn't exist or is unreadable."; 40 exit 1; 41 } 42 43 my $target = $self->get_cache_for_source($source); 44 $self->sync_cache_from_source( target => $target, source => $source ); 45 print "\nDone.\n"; 46} 47 48sub validate_args { 49 my $self = shift; 50 unless ( $self->has_arg('from') ) { 51 warn "No --from specified!\n"; 52 $self->print_usage; 53 } 54} 55 56__PACKAGE__->meta->make_immutable; 57no Any::Moose; 58 591; 60 61__END__ 62 63=pod 64 65=head1 NAME 66 67Prophet::CLI::Command::Mirror 68 69=head1 VERSION 70 71version 0.751 72 73=head1 AUTHORS 74 75=over 4 76 77=item * 78 79Jesse Vincent <jesse@bestpractical.com> 80 81=item * 82 83Chia-Liang Kao <clkao@bestpractical.com> 84 85=item * 86 87Christine Spang <christine@spang.cc> 88 89=back 90 91=head1 COPYRIGHT AND LICENSE 92 93This software is Copyright (c) 2009 by Best Practical Solutions. 94 95This is free software, licensed under: 96 97 The MIT (X11) License 98 99=head1 BUGS AND LIMITATIONS 100 101You can make new bug reports, and view existing ones, through the 102web interface at L<https://rt.cpan.org/Public/Dist/Display.html?Name=Prophet>. 103 104=head1 CONTRIBUTORS 105 106=over 4 107 108=item * 109 110Alex Vandiver <alexmv@bestpractical.com> 111 112=item * 113 114Casey West <casey@geeknest.com> 115 116=item * 117 118Cyril Brulebois <kibi@debian.org> 119 120=item * 121 122Florian Ragwitz <rafl@debian.org> 123 124=item * 125 126Ioan Rogers <ioanr@cpan.org> 127 128=item * 129 130Jonas Smedegaard <dr@jones.dk> 131 132=item * 133 134Kevin Falcone <falcone@bestpractical.com> 135 136=item * 137 138Lance Wicks <lw@judocoach.com> 139 140=item * 141 142Nelson Elhage <nelhage@mit.edu> 143 144=item * 145 146Pedro Melo <melo@simplicidade.org> 147 148=item * 149 150Rob Hoelz <rob@hoelz.ro> 151 152=item * 153 154Ruslan Zakirov <ruz@bestpractical.com> 155 156=item * 157 158Shawn M Moore <sartak@bestpractical.com> 159 160=item * 161 162Simon Wistow <simon@thegestalt.org> 163 164=item * 165 166Stephane Alnet <stephane@shimaore.net> 167 168=item * 169 170Unknown user <nobody@localhost> 171 172=item * 173 174Yanick Champoux <yanick@babyl.dyndns.org> 175 176=item * 177 178franck cuny <franck@lumberjaph.net> 179 180=item * 181 182robertkrimen <robertkrimen@gmail.com> 183 184=item * 185 186sunnavy <sunnavy@bestpractical.com> 187 188=back 189 190=cut 191