2024-12-30 14:10:05 +00:00
|
|
|
#| Utilities for interacting with idris and associated tooling
|
2024-12-30 13:43:26 +00:00
|
|
|
unit module IUtils;
|
|
|
|
|
|
|
|
need IUtils::IDEMode;
|
2024-12-30 14:38:52 +00:00
|
|
|
|
|
|
|
# Utility functions for pack
|
|
|
|
|
|
|
|
#| Invoke a pack command
|
|
|
|
sub pack-run(*@cmd) is export {
|
|
|
|
my $proc = run "pack", @cmd, :out, :err;
|
|
|
|
my $out = $proc.out.slurp(:close);
|
|
|
|
my $err = $proc.err.slurp(:close);
|
|
|
|
unless $proc {
|
|
|
|
die qq:to/END/;
|
|
|
|
Pack Failure!
|
|
|
|
Captured Output:
|
|
|
|
$out
|
|
|
|
|
|
|
|
Captured StdErr:
|
|
|
|
$err
|
|
|
|
END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Build a package with pack
|
|
|
|
sub pack-build($pkg) is export {
|
|
|
|
pack-run 'build', $pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Test a package with pack
|
|
|
|
sub pack-test($pkg) is export {
|
|
|
|
pack-run 'build', $pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Clean a package with pack
|
|
|
|
sub pack-clean($pkg) is export {
|
|
|
|
pack-run 'clean', $pkg;
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Invoke an idris command
|
|
|
|
sub idris-run(*@cmd) is export {
|
|
|
|
my $proc = run "idris2", @cmd, :out, :err;
|
|
|
|
my $out = $proc.out.slurp(:close);
|
|
|
|
my $err = $proc.err.slurp(:close);
|
|
|
|
unless $proc {
|
|
|
|
($out, $err)
|
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#| Exec the expression with the given name in the given file
|
|
|
|
sub idris-exec($expr, $file) is export {
|
|
|
|
idris-run '--find-ipkg', '--exec', $expr, $file
|
|
|
|
}
|