mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
feat: Refactor CLI config-ssh to improve UX (#1900)
- Magic block is replaced by Include statement - Writes are only done on changes - Inform user of changes via prompt - Allow displaying changes via `--diff` - Remove magic block if present - Safer config writing via tmp-file + rename - Parse previous `config-ssh` options, compare to new options and ask to use new (otherwise old ones are used) - Tests the new functionality Fixes #1326
This commit is contained in:
committed by
GitHub
parent
945fa9dacf
commit
b65259f95e
18
cli/root.go
18
cli/root.go
@ -244,6 +244,24 @@ func isTTY(cmd *cobra.Command) bool {
|
||||
return isatty.IsTerminal(file.Fd())
|
||||
}
|
||||
|
||||
// isTTYOut returns whether the passed reader is a TTY or not.
|
||||
// This accepts a reader to work with Cobra's "OutOrStdout"
|
||||
// function for simple testing.
|
||||
func isTTYOut(cmd *cobra.Command) bool {
|
||||
// If the `--force-tty` command is available, and set,
|
||||
// assume we're in a tty. This is primarily for cases on Windows
|
||||
// where we may not be able to reliably detect this automatically (ie, tests)
|
||||
forceTty, err := cmd.Flags().GetBool(varForceTty)
|
||||
if forceTty && err == nil {
|
||||
return true
|
||||
}
|
||||
file, ok := cmd.OutOrStdout().(*os.File)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return isatty.IsTerminal(file.Fd())
|
||||
}
|
||||
|
||||
func usageTemplate() string {
|
||||
// usageHeader is defined in init().
|
||||
return `{{usageHeader "Usage:"}}
|
||||
|
Reference in New Issue
Block a user