fix: enable OSC 8 hyperlinks by default in TTY terminals

What does this MR do?

Enables OSC 8 terminal hyperlinks by default in TTY output. Previously, hyperlinks were off unless the user opted in with display_hyperlinks: true or FORCE_HYPERLINKS=1.

Changes

  • Change the default hyperlink mode from "never" to "auto" in iostreams.New(). "auto" emits hyperlinks only when stdout is a TTY and not paged.
  • Centralize the test default to "never" in cmdtest.TestIOStreams so existing tests stay unaffected.
  • Add display_hyperlinks: false as the documented opt-out. display_hyperlinks: true now maps to "auto" (preserves the existing TTY-only semantics for users who already opted in).
  • Fix a precedence bug where a falsy FORCE_HYPERLINKS=0 or GLAB_FORCE_HYPERLINKS=0 would silently override display_hyperlinks: false. Falsy env values now fall through to the config.
  • Extract the hyperlink configuration logic into a testable configureHyperlinks function and add TestMain_configureHyperlinks covering the precedence matrix.
  • Add a DisplayHyperlinks() getter to IOStreams for test inspection.

Behavior matrix

Env var display_hyperlinks Resulting mode
FORCE_HYPERLINKS=1 any always
GLAB_FORCE_HYPERLINKS=1 any always
FORCE_HYPERLINKS=0 or falsy false never
FORCE_HYPERLINKS=0 or falsy true auto
unset false never
unset true auto
unset unset auto (new default)

How to test

Run glab api --help in a supported terminal without any environment variables or config changes. The "GitLab REST API documentation" and "GitLab GraphQL documentation" links should be clickable.

To verify a falsy FORCE_HYPERLINKS no longer overrides the config opt-out (comment 1 fix):

glab config set display_hyperlinks false
FORCE_HYPERLINKS=0 glab api --help

Links should appear as plain text.

Edited by Brendan Lynch

Merge request reports

Loading