| 1 | package JiftyX::Fixtures::Script::Clean; | ||
| 2 | our $VERSION = '0.07'; | ||
| 3 | |||
| 4 | # ABSTRACT: clean subcommand | ||
| 5 | |||
| 6 | use warnings; | ||
| 7 | use strict; | ||
| 8 | |||
| 9 | use Jifty; | ||
| 10 | use Jifty::Everything; | ||
| 11 | |||
| 12 | use IO::File; | ||
| 13 | use File::Basename; | ||
| 14 | use File::Spec; | ||
| 15 | use File::Path; | ||
| 16 | use YAML qw(Dump LoadFile); | ||
| 17 | |||
| 18 | use base qw( | ||
| 19 | App::CLI::Command | ||
| 20 | ); | ||
| 21 | |||
| 22 | my $super = 'JiftyX::Fixtures::Script'; | ||
| 23 | |||
| 24 | our $help_msg = qq{ | ||
| 25 | Usage: | ||
| 26 | |||
| 27 | jiftyx-fixtures clean [options] | ||
| 28 | |||
| 29 | Options: | ||
| 30 | |||
| 31 | -h, --help: show help | ||
| 32 | |||
| 33 | }; | ||
| 34 | |||
| 35 | sub options { | ||
| 36 | my ($self) = @_; | ||
| 37 | return ( | ||
| 38 | $super->options, | ||
| 39 | ); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub before_run { | ||
| 43 | my ($self) = @_; | ||
| 44 | |||
| 45 | $super->before_run($self); | ||
| 46 | |||
| 47 | return; | ||
| 48 | } | ||
| 49 | |||
| 50 | sub run { | ||
| 51 | my ($self) = @_; | ||
| 52 | $self->before_run(); | ||
| 53 | |||
| 54 | for (keys %{$self->{config}->{fixtures}}) { | ||
| 55 | my $dir = File::Spec->catfile( | ||
| 56 | $self->{config}->{app_root}, | ||
| 57 | $self->{config}->{fixtures}->{$_}->{dir} | ||
| 58 | ); | ||
| 59 | rmtree $dir; | ||
| 60 | } | ||
| 61 | rmdir File::Spec->catfile( | ||
| 62 | $self->{config}->{app_root}, | ||
| 63 | "etc", | ||
| 64 | "fixtures" | ||
| 65 | ); | ||
| 66 | unlink File::Spec->catfile( | ||
| 67 | $self->{config}->{app_root}, | ||
| 68 | "etc", | ||
| 69 | "fixtures.yml" | ||
| 70 | ); | ||
| 71 | |||
| 72 | |||
| 73 | } | ||
| 74 | |||
| 75 | 1; | ||
| 76 | |||
| 77 | __END__ |