From: Matt S Trout Date: Sun, 6 Nov 2011 21:41:06 +0000 (+0000) Subject: trivial command service X-Git-Tag: v0.001001~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b96be97f13c5b13762d63e25fc0adc3cb8736e60;p=scpubgit%2FTak.git trivial command service --- diff --git a/lib/Tak/CommandService.pm b/lib/Tak/CommandService.pm new file mode 100644 index 0000000..b311c82 --- /dev/null +++ b/lib/Tak/CommandService.pm @@ -0,0 +1,18 @@ +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;