added a cli flag to skip update checks (close #1586) (#1600)

adds a global flag `--skip-update-check`
This commit is contained in:
Aravind Shankar
2019-02-14 11:46:36 +05:30
committed by Shahidh K Muhammed
parent 199a24d050
commit d489f2d90f
2 changed files with 6 additions and 2 deletions

View File

@@ -123,6 +123,9 @@ type ExecutionContext struct {
// LastUpdateCheckFile is the file where the timestamp of last update check is stored
LastUpdateCheckFile string
// SkipUpdateCheck will skip the auto update check if set to true
SkipUpdateCheck bool
}
// NewExecutionContext returns a new instance of execution context

View File

@@ -32,7 +32,7 @@ var rootCmd = &cobra.Command{
ec.Telemetry.Command = cmd.CommandPath()
if cmd.Use != updateCLICmdUse {
if update.ShouldRunCheck(ec.LastUpdateCheckFile) && ec.GlobalConfig.ShowUpdateNotification {
if update.ShouldRunCheck(ec.LastUpdateCheckFile) && ec.GlobalConfig.ShowUpdateNotification && !ec.SkipUpdateCheck {
u := &updateOptions{
EC: ec,
}
@@ -68,7 +68,8 @@ func init() {
rootCmd.SetHelpCommand(NewHelpCmd(ec))
f := rootCmd.PersistentFlags()
f.StringVar(&ec.LogLevel, "log-level", "INFO", "log level (DEBUG, INFO, WARN, ERROR, FATAL)")
f.StringVar(&ec.ExecutionDirectory, "project", "", "directory where commands are executed. (default: current dir)")
f.StringVar(&ec.ExecutionDirectory, "project", "", "directory where commands are executed (default: current dir)")
f.BoolVar(&ec.SkipUpdateCheck, "skip-update-check", false, "Skip automatic update check on command execution")
}
// Execute executes the command and returns the error