package DX::Lib::FS::Action::SetPathMode;

use DX::Lib::FS::Guts;
use Moo;

has path_status => (is => 'ro', required => 1);
has mode => (is => 'ro', required => 1);

with 'DX::Role::Action';

sub expected_effect {
  my ($self) = @_;
  my $ps = $self->path_status;
  +(path_status => $ps->but(info => $ps->info->but(mode => $self->mode)));
}

sub _do_run {
  my ($self) = @_;
  DX::Lib::FS::Guts->set_path_mode($self->path, $self->mode);
  +(path_status => $self->path);
}

1;
