Disable completion (not working well)
[src/xds/xds-cli.git] / main.go
diff --git a/main.go b/main.go
index 2dfd056..9ac751c 100644 (file)
--- a/main.go
+++ b/main.go
@@ -26,12 +26,12 @@ import (
        "regexp"
        "sort"
        "strings"
+       "syscall"
        "text/tabwriter"
 
        "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1"
        common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
        "github.com/Sirupsen/logrus"
-
        "github.com/joho/godotenv"
        "github.com/urfave/cli"
 )
@@ -148,7 +148,10 @@ func main() {
        app.Metadata["version"] = AppVersion
        app.Metadata["git-tag"] = AppSubVersion
        app.Metadata["logger"] = Log
-       app.EnableBashCompletion = true
+       // FIXME: Disable completion for now, because it's not working with options
+       // (eg. --label) and prevents to complete local path
+       // (IOW current function only completes command and sub-commands)
+       app.EnableBashCompletion = false
 
        // Create env vars help
        dynDesc := "\nENVIRONMENT VARIABLES:"
@@ -324,6 +327,20 @@ func main() {
        // Start signals monitoring routine
        MonitorSignals()
 
+       // Default callback to handle interrupt signal
+       // Maybe be overwritten by some subcommand (eg. targets commands)
+       err := OnSignals(func(sig os.Signal) {
+               Log.Debugf("Send signal %v (from main)", sig)
+               if IsInterruptSignal(sig) {
+                       err := cli.NewExitError("Interrupted\n", int(syscall.EINTR))
+                       cli.HandleExitCoder(err)
+               }
+       })
+       if err != nil {
+               cli.NewExitError(err.Error(), 1)
+               return
+       }
+
        // Run the cli app
        app.Run(os.Args)
 }