bwbox/main.nim

28 lines
447 B
Nim
Raw Normal View History

2021-05-18 22:10:35 +02:00
import lib/sandbox
import lib/modes
2021-05-16 20:35:01 +02:00
import strformat
import strutils
2021-05-16 20:35:01 +02:00
import os
2021-05-18 22:10:35 +02:00
proc main() =
let mode = parseEnum[Modes](paramStr(0))
2021-05-18 22:10:35 +02:00
let args = commandLineParams()
let argc = paramCount()
2021-05-16 20:35:01 +02:00
2021-05-18 22:10:35 +02:00
if argc == 0:
echo &"Usage: {mode} <sandbox> [command]"
quit(1)
2021-05-16 20:35:01 +02:00
2021-05-18 22:10:35 +02:00
let name = args[0]
var command: string
2021-05-16 20:35:01 +02:00
2021-05-18 22:10:35 +02:00
if argc > 1:
command = args[1]
else:
command = getEnv("SHELL", "/bin/sh")
2021-05-16 20:35:01 +02:00
sandboxExec(name, command, mode)
2021-05-16 20:35:01 +02:00
2021-05-18 22:10:35 +02:00
main()