Commit graph

105 commits

Author SHA1 Message Date
Ville Skyttä
d8b8655f21 Grammar fixes 2026-05-01 10:22:13 +03:00
Kynan Ware
4661c05ed0 Fix gofmt alignment for prompter-enabled fields in IOStreams
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 14:24:56 +01:00
Kynan Ware
87426ee236 Add experimental huh-only prompter gated by GH_EXPERIMENTAL_PROMPTER
Introduce a new Prompter implementation (huhPrompter) that uses the
charmbracelet/huh library in its standard interactive mode, as an
alternative to the survey-based default prompter. The new implementation
is gated behind the GH_EXPERIMENTAL_PROMPTER environment variable,
following the same truthy/falsey pattern as GH_ACCESSIBLE_PROMPTER.

Key differences from the accessible prompter:
- No WithAccessible(true) flag (full interactive TUI)
- Uses EchoModePassword (masked with *) instead of EchoModeNone
- No default value annotations appended to prompt text

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 14:24:56 +01:00
Babak K. Shandiz
05986e4cb3
chore: apply go fix to remove deprecated // +build tags
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-30 21:10:45 +00:00
Kynan Ware
138bccd437 feat(config): add accessible prompter and spinner 2025-04-22 16:50:58 -06:00
Kynan Ware
056d292f26 doc(iostreams): comment behavior of textual progress indicator 2025-04-16 11:13:58 -06:00
Kynan Ware
290e78c904 test(iostreams): update test description 2025-04-16 11:05:36 -06:00
Kynan Ware
f283d6d11c feat(iostreams): textual progress indicator does not clear screen
This bypasses the `spinner` package for the textual progress indicator for users
with the spinner disabled out of concerns for accessibility, specifically
with screen readers:

- The `spinner` package will continuously re-draw the screen. I wasn't
able to have this cause problems with my Mac screen reader, but it's
nonetheless a concern that other screen readers may not handle this
screen re-drawing well.
- The `spinner` package clears any progress indicator messages from the screen
when stopping the progress indicator or changing its label.
This is a problem because it interrupts screen readers and leaves no way
to recover what the loading message was by scrolling up in the terminal.

NOTE: this new implementation still interrupts the screen reader when
the a new label is printed, but it does not clear the screen. This makes
the loading messages recoverable, at least.
2025-04-14 19:30:05 -06:00
Kynan Ware
3eba461afb fix(iostreams): spinner env var is now in factory
- Move env var evaluation to the factory defaults.
- Use only the label for the spinner instead of adding
"working..." every time. "working..." remains the default
when no label is provided.
2025-04-14 15:07:11 -06:00
Kynan Ware
3aadd51096 feat(iostreams): Option to opt out of spinners 2025-04-11 16:18:50 -06:00
Andy Feller
47225bcf56
Merge pull request #10737 from cli/andyfeller/muted-text-part2-github-cli-833
Ensure muted text is thematic and customizable
2025-04-08 16:59:36 -04:00
Andy Feller
918cafc222 Deprecate ColorScheme.Gray for ColorScheme.Muted
This commit converts all of the places using ColorScheme.Gray and ColorScheme.Grayf to Muted and Mutedf.

There is a little extra tidying up with local variable names or converting code to use Mutedf format.
2025-04-06 10:18:48 -04:00
Andy Feller
e067eacd81 Refactor ColorScheme initializer
This commit completely removes the iostreams.NewColorScheme() initializer function in favor of exporting the type fields for greater clarity in its use.

The result being code specifying only the fields that matter to test cases.
2025-04-04 11:57:37 -04:00
Andy Feller
e9a12853cb Merge branch 'trunk' into andyfeler/colorize-label-optin 2025-04-04 09:47:41 -04:00
Andy Feller
3eca268a7f Introduce color_labels support, update commands
This commit implements the actual changes around configuration setting / environment variable logic for displaying labels using their RGB hex color code in terminals with truecolor support.

One of the subtler changes in this commit is renaming generic ColorScheme.HexToRGB logic to render truecolor to ColorScheme.Label as this feature was being used exclusively for labels.  This is due to confusion about introducing the new `color_labels` config on top of generic coloring logic.
2025-04-02 18:24:20 -04:00
Andy Feller
b3c8c70cba Remove deprecated note on gray color functions
Without fixing all ColorScheme.Gray and ColorScheme.Grayf usage in this pull request, golangci-lint throws errors for using deprecated functions.

As that code should be replaced within github/cli#833, I'm removing the deprecation indicator for now to get this PR passing.
2025-03-31 17:00:40 -04:00
Andy Feller
3c38cedaf3 Implement tests for muted logic, standardize reset
This commit covers testing around the new ColorScheme.Muted logic based on various situations to gain confidence we get the accessible colors expected when enabled.

Additionally, this commit includes a small change to the existing 8-bit color logic to standardize on the same reset sequence for testing purposes.  Essentially, `ESC[m` and `ESC[0m` are equivalent but this inconsistency with our other libraries makes setting up tests a little extra confusing and difficult.
2025-03-31 15:33:52 -04:00
Andy Feller
346fab212b Accessible color config boilerplate, colors update
This commit is focused on incorporating cli/go-gh accessible colors configuration setting into GitHub CLI experience along with new color function to supersede ColorScheme.Gray and ColorScheme.Grayf.

Originally, I was considering having all use of ColorScheme.Gray and ColorScheme.Grayf fallback to the new muted logic if accessible colors were enabled, however I decided not being that it exceeds the acceptance criteria.  This means that every command using ColorScheme.Gray needs to be updated to use ColorScheme.Muted
2025-03-31 11:19:51 -04:00
Andy Feller
eabd02793e Renaming tabl eheader variables for maintainability 2025-03-28 13:19:27 -04:00
Andy Feller
79f1b07fb1 Implement and fix tests for table headers 2025-03-25 15:29:05 -04:00
Andy Feller
736ce69f66 Underline table headers if colors enabled but no theme
This enhances the table header stylizing logic to ensure they are underlined if color is enabled but no theme is desired.
2025-03-21 12:27:09 -04:00
Andy Feller
6355e54e3c Ensure table headers are thematically contrasting
This commit refactors the color format around table headers to ensure the GitHub CLI uses thematically appropriate colors based on dark background, light background, or no color at all.

In order to do so, `ColorScheme` needs information from the terminal about the background appearance (dark, light, none) to determine appropriate muted color.
2025-03-21 11:51:03 -04:00
petercover
bad7098cfe chore: fix some comments
Signed-off-by: petercover <raowanxiang@outlook.com>
2025-01-23 00:47:27 +08:00
Heath Stewart
70b14215ec
Print filtered gists similar to code search 2024-10-12 23:17:56 -07:00
Heath Stewart
7738b6187c
Add headers to all tables (#8157) 2023-10-20 11:20:02 +02:00
Sam Coe
8016244dbb
Use go-gh prompter package (#7896) 2023-08-28 08:08:43 -05:00
Josh Kraft
d82c65ac2f change highlight color 2023-04-26 19:15:31 -06:00
Josh Kraft
b8f86f54ad Merge branch 'trunk' into gh-search-code 2023-04-26 18:48:24 -06:00
Josh Kraft
65720e498e implement code search
updates
2023-04-26 18:38:35 -06:00
Sam Coe
dbc2f05124
Update go-gh to v2 (#7299)
* Update go-gh

* Update code for go-gh v2
2023-04-16 15:34:23 +10:00
JP Ungaretti
1b88915a4d Rename f to run 2023-02-09 23:16:12 +00:00
JP Ungaretti
43783a33a2 Move helper to iostreams 2023-02-09 22:23:58 +00:00
Sam Coe
c066edc984
Fix commands that use iostreams RefreshScreen (#6607) 2022-11-14 16:08:00 +01:00
Mislav Marohnić
58b12bfd13
Fake terminal-like object in tests 2022-10-25 16:56:28 +02:00
Mislav Marohnić
66282b6819
Restore color override 2022-10-24 17:15:06 +02:00
Mislav Marohnić
25a926d5cb
Dogfood term package from go-gh 2022-10-11 14:29:50 +02:00
Mislav Marohnić
efe504eefc Fix color output for non-256 color terminals
The function enableVirtualTerminalProcessing must return an error if
virtual terminal processing (only applicable on Windows) was not
enabled, otherwise we assume that the terminal supports both 256-color
and truecolor.

We have been erroneously assuming that all non-Windows terminals are
256-color and sending escape sequences to those that cannot intepret
them. This led to some parts of Survey prompts being invisible on old
terminals.

Regressed in be4b392530
2022-09-27 19:50:05 +02:00
Eng Zer Jun
471cbea4fa
test: use t.Setenv to set env vars in tests (#6333)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-09-26 08:46:02 +00:00
Mislav Marohnić
58ef50ae1f Ensure that subprocesses connect to the original os.Stdout
On non-Windows platforms, this avoids wrapping `IOStreams.Out` in a
`fdWriter` and thus causing subprocesses to lose connection to the
terminal that gh is connected to.
2022-09-14 16:47:42 +02:00
Mislav Marohnić
e2e8d697db
Fix closing IOStreams.Out after finishing writing to the pager (#6210) 2022-09-06 19:22:31 +02:00
Mislav Marohnić
436d9ef859
Fix "missing method Fd" crash on Windows (#6200)
This ensures that `IOStreams.Out` always keeps the original `Fd()` value even if it's wrapped as a Colorable stream for Windows in cases when enabling virtual terminal processing has failed.
2022-09-06 17:29:06 +02:00
Heath Stewart
c2f51f37bb Switch to main buffer on SIGINT
Fixes #6001
2022-07-26 20:47:33 -07:00
Heath Stewart
1ed80ffd45 Resolve PR feedback 2022-06-23 00:53:34 -07:00
Heath Stewart
be4b392530 Use alternate screen buffer for watching runs
Resolves #5679
2022-05-23 22:18:11 -07:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Heath Stewart
fc8739cf97
Add column for listing the label color (#5462)
Fixes #5448
2022-04-14 08:51:37 +02:00
Mark Phelps
a9e92c9ed5
Fix HexToRGB panic (#5247) 2022-03-01 14:37:10 +00:00
Mislav Marohnić
0a5e220231 Ignore EPIPE errors when writing to a closed pager
While a gh command is writing stdout to a pager, the user may choose to
close the pager program before the pager has read all the data on its
standard input. In that case, the parent gh process will receive an
EPIPE error, which would bubble up its error handling and cause it to
print something like:

    write |1: broken pipe

Since this was caused by an explicit user action of closing the pager,
and since the user probably doesn't want to see this uninformative
error, this informs our global error handling of this error and causes
it to be ignored.
2022-02-10 16:42:00 +01:00
Mislav Marohnić
659eed777d Have TerminalTheme invoke DetectTerminalTheme if necessary 2022-01-14 15:42:02 +01:00
Mislav Marohnić
d02f184bd1 go fmt 2021-12-02 16:12:24 +01:00