From c963b977d3f95f76638d4d18571331b0d89cc507 Mon Sep 17 00:00:00 2001 From: Ken Sipe Date: Wed, 9 Feb 2022 08:52:26 -0600 Subject: [PATCH 1/2] Deprecate --hud in favor of --legacy Signed-off-by: Ken Sipe --- internal/cli/demo.go | 17 +++++++++++++---- internal/cli/up.go | 16 +++++----------- internal/cli/up_test.go | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/internal/cli/demo.go b/internal/cli/demo.go index 9a0b9d5be8..df2574fe34 100644 --- a/internal/cli/demo.go +++ b/internal/cli/demo.go @@ -23,7 +23,7 @@ const demoResourcesPrefix = "tilt-demo-" const sampleProjPackage = "github.com/tilt-dev/tilt-avatars" type demoCmd struct { - hud bool + legacy bool teardown bool @@ -52,9 +52,12 @@ A sample project (%s) will be cloned locally to a temporary directory using Git "Removes any leftover tilt-demo Kubernetes clusters and exits") // --hud flag only exists for integration tests to disable web console - cmd.Flags().BoolVar(&c.hud, "hud", true, "If true, tilt will open in HUD mode.") + cmd.Flags().BoolVar(&c.legacy, "hud", true, "If true, tilt will open in legacy HUD mode. (deprecated: please use --legacy)") // TODO: remove --hud completely by v0.27.0 cmd.Flags().Lookup("hud").Hidden = true + cmd.Flags().BoolVar(&c.legacy, "legacy", true, "If true, tilt will open in legacy HUD mode.") + cmd.Flags().Lookup("legacy").Hidden = true + // --tmpdir exists so that integration tests can inspect the output / use the Tiltfile cmd.Flags().StringVarP(&c.tmpdir, "tmpdir", "", "", "Temporary directory to clone sample project to") @@ -73,6 +76,13 @@ A sample project (%s) will be cloned locally to a temporary directory using Git addStartServerFlags(cmd) addDevServerFlags(cmd) + cmd.PreRun = func(cmd *cobra.Command, args []string) { + if cmd.Flag("hud").Changed { + fmt.Fprint(os.Stderr, "--hud is deprecated. Please switch to --legacy.") // TODO: remove --hud completely by v0.27.0 + time.Sleep(3 * time.Second) + } + } + return cmd } @@ -190,8 +200,7 @@ Open the project directory in your preferred editor: // up := upCmd{ fileName: c.tiltfilePath, - hud: c.hud, - legacy: false, + legacy: c.legacy, stream: false, } return up.run(ctx, args) diff --git a/internal/cli/up.go b/internal/cli/up.go index 928f3f50f0..3ea033513d 100644 --- a/internal/cli/up.go +++ b/internal/cli/up.go @@ -43,11 +43,8 @@ type upCmd struct { fileName string outputSnapshotOnExit string - hud bool legacy bool stream bool - // whether hud/legacy/stream flags were explicitly set or just got the default value - hudFlagExplicitlySet bool } func (c *upCmd) name() model.TiltSubcommand { return "up" } @@ -79,7 +76,7 @@ local resources--i.e. those using serve_cmd--are terminated when you exit Tilt. cmd.Flags().StringVar(&updateModeFlag, "update-mode", string(liveupdates.UpdateModeAuto), fmt.Sprintf("Control the strategy Tilt uses for updating instances. Possible values: %v", liveupdates.AllUpdateModes)) - cmd.Flags().BoolVar(&c.hud, "hud", true, "If true, tilt will open in HUD mode.") + cmd.Flags().BoolVar(&c.legacy, "hud", false, "If true, tilt will open in legacy terminal mode. (deprecated: please use --legacy)") // TODO: remove --hud completely by v0.27.0 cmd.Flags().BoolVar(&c.legacy, "legacy", false, "If true, tilt will open in legacy terminal mode.") cmd.Flags().BoolVar(&c.stream, "stream", false, "If true, tilt will stream logs in the terminal.") cmd.Flags().BoolVar(&logActionsFlag, "logactions", false, "log all actions and state changes") @@ -92,7 +89,10 @@ local resources--i.e. those using serve_cmd--are terminated when you exit Tilt. cmd.Flags().StringVar(&c.outputSnapshotOnExit, "output-snapshot-on-exit", "", "If specified, Tilt will dump a snapshot of its state to the specified path when it exits") cmd.PreRun = func(cmd *cobra.Command, args []string) { - c.hudFlagExplicitlySet = cmd.Flag("hud").Changed + if cmd.Flag("hud").Changed { + fmt.Fprint(os.Stderr, "--hud is deprecated. Please switch to --legacy.") // TODO: remove --hud completely by v0.27.0 + time.Sleep(3 * time.Second) + } } return cmd @@ -103,12 +103,6 @@ func (c *upCmd) initialTermMode(isTerminal bool) store.TerminalMode { return store.TerminalModeStream } - if c.hudFlagExplicitlySet { - if c.hud { - return store.TerminalModeHUD - } - } - if c.legacy { return store.TerminalModeHUD } diff --git a/internal/cli/up_test.go b/internal/cli/up_test.go index 19912fbe9a..ddd98a8321 100644 --- a/internal/cli/up_test.go +++ b/internal/cli/up_test.go @@ -16,7 +16,7 @@ func TestHudEnabled(t *testing.T) { expected store.TerminalMode }{ {"old behavior: no --hud", "", store.TerminalModePrompt}, - {"old behavior: --hud", "--hud", store.TerminalModeHUD}, + {"old behavior: --legacy", "--legacy", store.TerminalModeHUD}, {"old behavior: --stream=true", "--stream=true", store.TerminalModeStream}, } { t.Run(test.name, func(t *testing.T) { From 2706d1bf89d161ffb21083e5304336760e3b82b7 Mon Sep 17 00:00:00 2001 From: Ken Sipe Date: Wed, 9 Feb 2022 09:52:37 -0600 Subject: [PATCH 2/2] resolving use of --hud in integration Signed-off-by: Ken Sipe --- Tiltfile | 2 +- integration/tilt.go | 2 +- internal/cli/args.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tiltfile b/Tiltfile index 30b7dfc671..a61f3578fc 100644 --- a/Tiltfile +++ b/Tiltfile @@ -34,7 +34,7 @@ def go_vendor(): all_go_files = get_all_go_files(".") -go("Tilt", "cmd/tilt/main.go", all_go_files, srv="cd /tmp/ && ./tilt up --hud=false --web-mode=prod --port=9765") +go("Tilt", "cmd/tilt/main.go", all_go_files, srv="cd /tmp/ && ./tilt up --legacy=false --web-mode=prod --port=9765") go_test_changes(all_go_files) go_lint(all_go_files) go_vendor() diff --git a/integration/tilt.go b/integration/tilt.go index a97327725d..e69f562746 100644 --- a/integration/tilt.go +++ b/integration/tilt.go @@ -110,7 +110,7 @@ func (d *TiltDriver) Up(ctx context.Context, command UpCommand, out io.Writer, a } mandatoryArgs := []string{string(command), // Can't attach a HUD or install browsers in headless mode - "--hud=false", + "--legacy=false", // Debug logging for integration tests "--debug", diff --git a/internal/cli/args.go b/internal/cli/args.go index 27924f3805..81d25798c2 100644 --- a/internal/cli/args.go +++ b/internal/cli/args.go @@ -59,7 +59,7 @@ EDITOR=nano tilt args # note: "--" here indicates the end of the tilt args and the start of the tiltfile args tilt args -- --foo=bar frontend backend -Note that this does not affect built-in Tilt args (e.g. --hud, --host), but rather the extra args that come after, +Note that this does not affect built-in Tilt args (e.g. --legacy, --host), but rather the extra args that come after, i.e., those specifying which resources to run and/or handled by a Tiltfile calling config.parse. `, }