package DX::Lib::FS::Action::CreateDirectory;

use aliased 'DX::Lib::FS::Fact::PathStatus';
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 => ($self->has_mode ? $self->mode : '')
    )
  ));
}

sub _do_run {
  my ($self) = @_;
  $self->_call_guts(create_directory => $self->mode);
  +(path_status => $self->path);
}

1;
