-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: decouple --output json from non-interactive mode #41
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -101,9 +101,6 @@ Examples: | |||||||||||||||||
| if outputFormat != "text" && outputFormat != "json" { | ||||||||||||||||||
| return fmt.Errorf("invalid output format %q: must be one of: text, json", outputFormat) | ||||||||||||||||||
| } | ||||||||||||||||||
| if isJSONOutput() { | ||||||||||||||||||
| ui.IsTerminalFunc = func(fd uintptr) bool { return false } | ||||||||||||||||||
| } | ||||||||||||||||||
| return nil | ||||||||||||||||||
| }, | ||||||||||||||||||
| RunE: runFn, | ||||||||||||||||||
|
||||||||||||||||||
| RunE: runFn, | |
| RunE: func(cmd *cobra.Command, args []string) error { | |
| originalIsTerminalFunc := ui.IsTerminalFunc | |
| defer func() { | |
| ui.IsTerminalFunc = originalIsTerminalFunc | |
| }() | |
| return runFn(cmd, args) | |
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
--output jsonno longer forces non-interactive mode, some commands can enter interactive flows while still expecting machine-readable output. At leastcmd/revoke.goprints human text to stdout on the “no active sessions” and “revocation canceled” paths, which will break consumers expecting JSON when-o jsonis set. Consider auditing interactive commands so that in JSON mode either (a) non-JSON messages go to stderr and stdout remains valid JSON, or (b) cancellation/empty states return a JSON payload (or a non-zero error) instead of plain text.