aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaarten Vanraes <alien@mageia.org>2016-03-20 10:22:52 +0100
committerMaarten Vanraes <alien@mageia.org>2016-05-14 09:25:24 +0200
commitf0be9670949426eb19317f101f8a053846183c95 (patch)
treed28f0326598f338f481cb4f831b8fac4844d4a43 /lib
parent14823e6597afe0458a53966b0552cfa2c763b822 (diff)
downloadmanatools-f0be9670949426eb19317f101f8a053846183c95.tar
manatools-f0be9670949426eb19317f101f8a053846183c95.tar.gz
manatools-f0be9670949426eb19317f101f8a053846183c95.tar.bz2
manatools-f0be9670949426eb19317f101f8a053846183c95.tar.xz
manatools-f0be9670949426eb19317f101f8a053846183c95.zip
Plugin: tool_exec implementation
Diffstat (limited to 'lib')
-rw-r--r--lib/ManaTools/Shared/disk_backend/Plugin.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/disk_backend/Plugin.pm b/lib/ManaTools/Shared/disk_backend/Plugin.pm
index 8bcd84bd..ebd4a02f 100644
--- a/lib/ManaTools/Shared/disk_backend/Plugin.pm
+++ b/lib/ManaTools/Shared/disk_backend/Plugin.pm
@@ -267,6 +267,41 @@ sub probeio {
#=============================================================
+=head2 tool_exec
+
+=head3 INPUT
+
+ $toolname: Str
+ @args: Array[Str]
+
+=head3 OUTPUT
+
+ Int: exitcode
+
+=head3 DESCRIPTION
+
+ this is a method for executing a tool and getting only the exit code
+
+=cut
+
+#=============================================================
+sub tool_exec {
+ my $self = shift;
+ my $toolname = shift;
+ my @args = @_;
+ my $tool = $self->tool($toolname);
+ # exit early if tool doesn't exit
+ return undef if (!defined($tool) || !$tool);
+
+ # insert tool before @args
+ unshift @args, $self->tool($toolname);
+
+ # get lines
+ return ManaTools::Shared::RunProgram::raw({exitcode => 1}, @args);
+}
+
+#=============================================================
+
=head2 tool_lines
=head3 INPUT