From 6df7c96f0f98850cbd289463d61ed2d521bc3e71 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 27 Oct 2018 08:14:10 +0000 Subject: [PATCH] Get rid of global kingpin --- main.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d74b936..3ed503a 100644 --- a/main.go +++ b/main.go @@ -429,17 +429,25 @@ func pewHandler(workPath, kcfgPath string) (err error) { } func main() { - pathFlag := kingpin.Flag("path", "Path to work directory") + app := kingpin.New( + "out-of-tree", + "kernel {module, exploit} development tool", + ) + + app.Author("Mikhail Klementev ") + app.Version("0.1.0") + + pathFlag := app.Flag("path", "Path to work directory") path := pathFlag.Default(".").ExistingDir() - kcfgFlag := kingpin.Flag("kernels", "Path to kernels config") + kcfgFlag := app.Flag("kernels", "Path to kernels config") kcfg := kcfgFlag.Envar("OUT_OF_TREE_KCFG").Required().ExistingFile() - kingpin.Command("pew", "Build, run and test module/exploit") + pewCommand := app.Command("pew", "Build, run and test module/exploit") var err error - switch kingpin.Parse() { - case "pew": + switch kingpin.MustParse(app.Parse(os.Args[1:])) { + case pewCommand.FullCommand(): err = pewHandler(*path, *kcfg) }