From 12b3c40e875eb8b820dbbdd7fceab0905e78f668 Mon Sep 17 00:00:00 2001 From: Leo Scordilis Date: Fri, 4 Oct 2024 14:40:53 -0400 Subject: [PATCH] Support BOSH_TTY environment variable for --tty flag This is convenient for CI/CD tools that may not run jobs in a tty. See https://github.com/actions/runner/issues/241 --- cmd/completion/completion_test.go | 2 +- cmd/opts/opts.go | 2 +- cmd/opts/opts_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/completion/completion_test.go b/cmd/completion/completion_test.go index 297db49f6..7e6b551d1 100644 --- a/cmd/completion/completion_test.go +++ b/cmd/completion/completion_test.go @@ -158,7 +158,7 @@ var globalFlags = []string{ "-n\tDon't ask for user input, env: BOSH_NON_INTERACTIVE", "--parallel\tThe max number of parallel operations", "--sha2\tUse SHA256 checksums, env: BOSH_SHA2", - "--tty\tForce TTY-like output", + "--tty\tForce TTY-like output, env: BOSH_TTY", "--version\tShow CLI version", "-v\tShow CLI version", } diff --git a/cmd/opts/opts.go b/cmd/opts/opts.go index a8766e599..1839e8ea4 100644 --- a/cmd/opts/opts.go +++ b/cmd/opts/opts.go @@ -31,7 +31,7 @@ type BoshOpts struct { // Output formatting ColumnOpt []ColumnOpt `long:"column" description:"Filter to show only given column(s), use the --column flag for each column you wish to include"` JSONOpt bool `long:"json" description:"Output as JSON"` - TTYOpt bool `long:"tty" description:"Force TTY-like output"` + TTYOpt bool `long:"tty" description:"Force TTY-like output" env:"BOSH_TTY"` NoColorOpt bool `long:"no-color" description:"Toggle colorized output"` NonInteractiveOpt bool `long:"non-interactive" short:"n" description:"Don't ask for user input" env:"BOSH_NON_INTERACTIVE"` diff --git a/cmd/opts/opts_test.go b/cmd/opts/opts_test.go index 41842daf1..094a9e685 100644 --- a/cmd/opts/opts_test.go +++ b/cmd/opts/opts_test.go @@ -180,7 +180,7 @@ var _ = Describe("Opts", func() { Describe("TTYOpt", func() { It("contains desired values", func() { Expect(getStructTagForName("TTYOpt", opts)).To(Equal( - `long:"tty" description:"Force TTY-like output"`, + `long:"tty" description:"Force TTY-like output" env:"BOSH_TTY"`, )) }) })