trivial command service
Matt S Trout [Sun, 6 Nov 2011 21:41:06 +0000 (21:41 +0000)]
lib/Tak/CommandService.pm [new file with mode: 0644]

diff --git a/lib/Tak/CommandService.pm b/lib/Tak/CommandService.pm
new file mode 100644 (file)
index 0000000..b311c82
--- /dev/null
@@ -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;