Refactor argument parsing
This commit is contained in:
		| @@ -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 :) |     $ rm -rf {Debian,CentOS,Ubuntu/{14.04,18.04}} # speed up :) | ||||||
|     $ ./bootstrap.sh |     $ ./bootstrap.sh | ||||||
|     $ # wait several hours... |     $ # 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 |     $ cd ../../examples/kernel-exploit | ||||||
|     $ # test kernel exploit |     $ # test kernel exploit | ||||||
|     $ out-of-tree pew |     $ out-of-tree pew | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.go
									
									
									
									
									
								
							| @@ -429,17 +429,18 @@ func pewHandler(workPath, kcfgPath string) (err error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| 	pewCommand := kingpin.Command("pew", "Build, run and test module/exploit") | 	pathFlag := kingpin.Flag("path", "Path to work directory") | ||||||
| 	path := pewCommand.Arg( | 	path := pathFlag.Default(".").ExistingDir() | ||||||
| 		"path", "Path to work directory").Default(".").ExistingDir() |  | ||||||
| 	kernelsConfig := pewCommand.Flag( | 	kcfgFlag := kingpin.Flag("kernels", "Path to kernels config") | ||||||
| 		"kernels-config", "Path to kernels config").Envar( | 	kcfg := kcfgFlag.Envar("OUT_OF_TREE_KCFG").Required().ExistingFile() | ||||||
| 		"OUT_OF_TREE_KERNELS_CONFIG").Required().ExistingFile() |  | ||||||
|  | 	kingpin.Command("pew", "Build, run and test module/exploit") | ||||||
|  |  | ||||||
| 	var err error | 	var err error | ||||||
| 	switch kingpin.Parse() { | 	switch kingpin.Parse() { | ||||||
| 	case "pew": | 	case "pew": | ||||||
| 		err = pewHandler(*path, *kernelsConfig) | 		err = pewHandler(*path, *kcfg) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user