Add --interactive flag
diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index c844260..aa504f3 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel
@@ -11,6 +11,7 @@ deps = [ "//bazel", "//buildinfo", + "@com_github_mattn_go_isatty//:go-isatty", "@com_github_mitchellh_go_homedir//:go-homedir", "@com_github_spf13_cobra//:cobra", "@com_github_spf13_viper//:viper",
diff --git a/cmd/root.go b/cmd/root.go index 9935bcb..8d9e513 100644 --- a/cmd/root.go +++ b/cmd/root.go
@@ -12,9 +12,11 @@ homedir "github.com/mitchellh/go-homedir" "github.com/spf13/viper" + "github.com/mattn/go-isatty" ) var cfgFile string +var interactive bool // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ @@ -41,9 +43,11 @@ rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.aspect.yaml)") - // Cobra also supports local flags, which will only run - // when this action is called directly. - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + interactive_default := false + if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) { + interactive_default = true + } + rootCmd.PersistentFlags().BoolVar(&interactive, "interactive", interactive_default, "Interactive mode (e.g. prompts for user input)") } // initConfig reads in config file and ENV variables if set.
diff --git a/cmd/version.go b/cmd/version.go index a5c06ea..2440206 100644 --- a/cmd/version.go +++ b/cmd/version.go
@@ -23,7 +23,7 @@ } else { version := buildinfo.Release if buildinfo.GitStatus != "clean" { - version += " (in a dirty clone)" + version += " (with local changes)" } fmt.Printf("Aspect version: %s\n", version) }
diff --git a/go.bzl b/go.bzl index e257ad5..ed22fc9 100644 --- a/go.bzl +++ b/go.bzl
@@ -42,6 +42,7 @@ ) go_repository( name = "com_github_bazelbuild_bazelisk", + build_naming_convention = "go_default_library", importpath = "github.com/bazelbuild/bazelisk", sum = "h1:2EWA2lRrt/k8B5ASt0mlTDQ+7mnzvKdF6ShNWLbk0o0=", version = "v1.10.1", @@ -501,8 +502,8 @@ go_repository( name = "com_github_mattn_go_isatty", importpath = "github.com/mattn/go-isatty", - sum = "h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=", - version = "v0.0.3", + sum = "h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=", + version = "v0.0.13", ) go_repository( name = "com_github_matttproud_golang_protobuf_extensions",
diff --git a/go.mod b/go.mod index fd7045c..9abbdfd 100644 --- a/go.mod +++ b/go.mod
@@ -6,6 +6,7 @@ github.com/bazelbuild/bazelisk v1.10.1 github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/magiconair/properties v1.8.5 // indirect + github.com/mattn/go-isatty v0.0.13 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/pelletier/go-toml v1.9.2 // indirect
diff --git a/go.sum b/go.sum index bbc71ac..4013186 100644 --- a/go.sum +++ b/go.sum
@@ -198,8 +198,9 @@ github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA= @@ -387,6 +388,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=