bunpen: split autodetect type into own file

This commit is contained in:
2024-08-30 16:28:03 +00:00
parent 735079e615
commit 25b3ccaa48
2 changed files with 21 additions and 19 deletions

View File

@@ -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;
};
};

View File

@@ -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;
};
};