better naming and help command for KeyMangler
[scpubgit/DKit.git] / lib / DX / Lib / FS / Action / CreateDirectory.pm
index ef11a20..cd90de1 100644 (file)
@@ -5,21 +5,27 @@ use aliased 'DX::Lib::FS::Fact::PathStatusInfo';
 use Moo;
 
 with 'DX::Role::Action';
+with 'DX::Lib::FS::Role::RunOn';
 
 has path => (is => 'ro', required => 1);
 
+has mode => (is => 'ro', predicate => 1);
+
 sub expected_effect {
   my ($self) = @_;
   return +(path_status => PathStatus->new(
     path => $self->path,
-    info => PathStatusInfo->new(is_directory => 1, mode => '')
+    info => PathStatusInfo->new(
+      is_directory => 1,
+      mode => ($self->has_mode ? $self->mode : '')
+    )
   ));
 }
 
 sub _do_run {
   my ($self) = @_;
-  mkdir($self->path) or die "Couldn't mkdir ${\$self->path}: $!";
-  +(path_status => PathStatus->new(path => $self->path));
+  $self->_call_guts(create_directory => $self->mode);
+  +(path_status => $self->path);
 }
 
 1;