package Tak::CommandService;

use Capture::Tiny qw(capture);
use IPC::System::Simple qw(runx EXIT_ANY);
use Moo;

with 'Tak::Role::Service';

sub handle_exec {
  my ($self, $command) = @_;
  my $code;
  my ($stdout, $stderr) = capture {
    $code = runx(EXIT_ANY, @$command);
  };
  return { stdout => $stdout, stderr => $stderr, exit_code => $code };
}

1;
