From 25b3ccaa48c368532eb77671fa9c0c25d0f70d13 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 30 Aug 2024 16:28:03 +0000 Subject: [PATCH] bunpen: split `autodetect` type into own file --- pkgs/additional/bunpen/config/autodetect.ha | 21 +++++++++++++++++++++ pkgs/additional/bunpen/config/cli.ha | 19 ------------------- 2 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 pkgs/additional/bunpen/config/autodetect.ha diff --git a/pkgs/additional/bunpen/config/autodetect.ha b/pkgs/additional/bunpen/config/autodetect.ha new file mode 100644 index 000000000..aaa1360dd --- /dev/null +++ b/pkgs/additional/bunpen/config/autodetect.ha @@ -0,0 +1,21 @@ +// vim: set shiftwidth=2 : + +export type autodetect = enum { + EXISTING, + EXISTING_FILE, + EXISTING_FILE_OR_PARENT, + EXISTING_OR_PARENT, + PARENT, +}; + +fn autodetect_fromstr(v: str) (autodetect | error) = { + return switch (v) { + case "existing" => yield autodetect::EXISTING; + case "existingFile" => yield autodetect::EXISTING_FILE; + case "existingFileOrParent" => yield autodetect::EXISTING_FILE_OR_PARENT; + case "existingOrParent" => yield autodetect::EXISTING_OR_PARENT; + case "parent" => yield autodetect::PARENT; + case => yield error; + }; +}; + diff --git a/pkgs/additional/bunpen/config/cli.ha b/pkgs/additional/bunpen/config/cli.ha index aff1a93d2..b8019be23 100644 --- a/pkgs/additional/bunpen/config/cli.ha +++ b/pkgs/additional/bunpen/config/cli.ha @@ -20,14 +20,6 @@ export type cli_opts = struct { run_paths: []str, }; -export type autodetect = enum { - EXISTING, - EXISTING_FILE, - EXISTING_FILE_OR_PARENT, - EXISTING_OR_PARENT, - PARENT, -}; - export fn usage() void = { fmt::println("bunpen: run a program within an environment where access to external resources (files, net, certain IPC, ...) is restricted (i.e. sandbox)")!; fmt::println("USAGE: bunpen [sandbox-arg ...] program [sandbox-arg|program-arg ...] [--] [program-arg ...]")!; @@ -120,14 +112,3 @@ fn expect_arg(name: str, value: nullable *str) (str | error) = { case let v: *str => yield *v; }; }; - -fn autodetect_fromstr(v: str) (autodetect | error) = { - return switch (v) { - case "existing" => yield autodetect::EXISTING; - case "existingFile" => yield autodetect::EXISTING_FILE; - case "existingFileOrParent" => yield autodetect::EXISTING_FILE_OR_PARENT; - case "existingOrParent" => yield autodetect::EXISTING_OR_PARENT; - case "parent" => yield autodetect::PARENT; - case => yield error; - }; -};