mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-07 16:09:10 +08:00
make bad flags exit with proper status code
This commit is contained in:
parent
4aac517d62
commit
63d496b4c7
2 changed files with 7 additions and 4 deletions
|
@ -36,7 +36,7 @@ var _ = cmd(catDebug, &cli.Command{
|
||||||
})
|
})
|
||||||
|
|
||||||
// Run will execute the CLI
|
// Run will execute the CLI
|
||||||
func Run(v string) error {
|
func Run(v string) int {
|
||||||
version = v
|
version = v
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Version = version
|
app.Version = version
|
||||||
|
@ -46,8 +46,10 @@ func Run(v string) error {
|
||||||
sort.Sort(cli.CommandsByName(commands))
|
sort.Sort(cli.CommandsByName(commands))
|
||||||
app.Commands = commands
|
app.Commands = commands
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Run(os.Args)
|
if err := app.Run(os.Args); err != nil {
|
||||||
return nil
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared config types
|
// Shared config types
|
||||||
|
|
3
main.go
3
main.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ import (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
commands.Run(versionString())
|
os.Exit(commands.Run(versionString()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version management. 2 Goals:
|
// Version management. 2 Goals:
|
||||||
|
|
Loading…
Reference in a new issue