| 1 | package HTTP::Balancer::Command::Init; | ||
| 2 | |||
| 3 | use Modern::Perl; | ||
| 4 | |||
| 5 | use Moose; | ||
| 6 | |||
| 7 | with qw( HTTP::Balancer::Role::Command ); | ||
| 8 | |||
| 9 | use Path::Tiny; | ||
| 10 | |||
| 11 | sub run { | ||
| 12 | my ($self, ) = @_; | ||
| 13 | |||
| 14 | require HTTP::Balancer::Model; | ||
| 15 | $self->mkpath( map { $_->model_dir } HTTP::Balancer::Model->models ); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub mkpath { | ||
| 19 | my ($self, @path) = @_; | ||
| 20 | |||
| 21 | for my $path (map { path($_) } @path) { | ||
| 22 | if ($path->exists) { | ||
| 23 | say "$path has existed."; | ||
| 24 | $path->mkpath; | ||
| 25 | } else { | ||
| 26 | say "create $path"; | ||
| 27 | $path->mkpath; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | $self; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; | ||
| 35 | __END__ |