Refactor argument parsing
This commit is contained in:
parent
672a8e6735
commit
1b9e72802d
@ -31,7 +31,7 @@ If you already have Go, Qemu and Docker installed, there's cross-platform instal
|
||||
$ rm -rf {Debian,CentOS,Ubuntu/{14.04,18.04}} # speed up :)
|
||||
$ ./bootstrap.sh
|
||||
$ # wait several hours...
|
||||
$ export OUT_OF_TREE_KERNELS_CONFIG=$GOPATH/src/github.com/jollheef/out-of-tree/tools/kernel-factory/output/kernels.toml
|
||||
$ export OUT_OF_TREE_KCFG=$GOPATH/src/github.com/jollheef/out-of-tree/tools/kernel-factory/output/kernels.toml
|
||||
$ cd ../../examples/kernel-exploit
|
||||
$ # test kernel exploit
|
||||
$ out-of-tree pew
|
||||
|
15
main.go
15
main.go
@ -429,17 +429,18 @@ func pewHandler(workPath, kcfgPath string) (err error) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
pewCommand := kingpin.Command("pew", "Build, run and test module/exploit")
|
||||
path := pewCommand.Arg(
|
||||
"path", "Path to work directory").Default(".").ExistingDir()
|
||||
kernelsConfig := pewCommand.Flag(
|
||||
"kernels-config", "Path to kernels config").Envar(
|
||||
"OUT_OF_TREE_KERNELS_CONFIG").Required().ExistingFile()
|
||||
pathFlag := kingpin.Flag("path", "Path to work directory")
|
||||
path := pathFlag.Default(".").ExistingDir()
|
||||
|
||||
kcfgFlag := kingpin.Flag("kernels", "Path to kernels config")
|
||||
kcfg := kcfgFlag.Envar("OUT_OF_TREE_KCFG").Required().ExistingFile()
|
||||
|
||||
kingpin.Command("pew", "Build, run and test module/exploit")
|
||||
|
||||
var err error
|
||||
switch kingpin.Parse() {
|
||||
case "pew":
|
||||
err = pewHandler(*path, *kernelsConfig)
|
||||
err = pewHandler(*path, *kcfg)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user