From 19f545f2b759a7b2281bf5053aff32f7a52d62d2 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sat, 25 Apr 2020 19:40:09 +0530 Subject: Initial version of pavo --- main.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..5a102b4 --- /dev/null +++ b/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "os" + "os/exec" +) + +var ( + version = "v0.1.0" + + cmd Config + flags []string +) + +func main() { + initPledge() + initUnveil() + + if len(os.Args) == 1 { + fmt.Println("Usage: pavo ") + os.Exit(1) + } + + if os.Args[1] == "version" { + fmt.Println("Pavo", version) + os.Exit(0) + } + + // Parse the config file. + parseConfig() + + // Block futher unveil calls. + blockUnveil() + + // Get path of command. + cmdPath, err := exec.LookPath(cmd.Command) + if err != nil { + fmt.Printf("%s %s :: %s\n", + cmd.Command, + "not found in $PATH", + err.Error()) + os.Exit(1) + } + + // TODO: Make the output realtime. + out, err := exec.Command(cmdPath, flags...).Output() + if err != nil { + err = fmt.Errorf("%s :: %s", + "Failed to execute command", + err.Error()) + os.Exit(1) + } + + // Print the output. + fmt.Printf(string(out)) +} -- cgit 1.4.1-2-gfad0 in'>about summary refs log blame commit diff stats
blob: d7558401fc4744aba21b310b44aee9c7e729eb8a (plain) (tree)
1
2
3
4
5
6
7
8
9