Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate --hud in favor of --legacy #5470

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion integration/tilt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
`,
}
Expand Down
17 changes: 13 additions & 4 deletions internal/cli/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 5 additions & 11 deletions internal/cli/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand 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")
Expand All @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down