From 6b0d4ee051f650b46af7ec50acf1122d44088fb5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 20 Apr 2022 10:12:14 +0100 Subject: modularize more --- lib/Katana/Exec/Command.rakumod | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/Katana/Exec/Command.rakumod (limited to 'lib/Katana/Exec') diff --git a/lib/Katana/Exec/Command.rakumod b/lib/Katana/Exec/Command.rakumod new file mode 100644 index 0000000..6cf0e38 --- /dev/null +++ b/lib/Katana/Exec/Command.rakumod @@ -0,0 +1,22 @@ +use v6.d; +unit module Katana::Exec::Command:api<1>; + +sub prefix:<❱>(*@args) is export { + say "❱ {@args}"; + my \proc = run @args, :out, :err; + .say if .chars > 0 for proc.out.slurp(:close), proc.err.slurp(:close); +} + +sub prefix:<⁉>(*@args) is export { ❱ @args unless @args[*-1].IO.f } + +sub read-exif-info(Str $file) is export { + my %exif; + my \proc = run 'exiftool', $file, :out; + for proc.out.slurp(:close).split("\n") -> $line { + my ($key, $val) = $line.split(':')[0,1]; + next unless defined $val; + %exif{$key.trim} = $val.trim; + } + return %exif; +} + -- cgit v1.2.3