Commit graph

60 commits

Author SHA1 Message Date
Babak K. Shandiz
d002d30327
fix: resolve nilerr issues
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:26 +00:00
juejinyuxitu
f5cf156af1 refactor: use strings.FieldsFuncSeq to reduce memory allocations
Signed-off-by: juejinyuxitu <juejinyuxitu@outlook.com>
2025-09-24 23:11:17 +08: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
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
d2cd14b4cd Remove out of scope changes, update list commands
After discussing this with the team, the `gh config` changes to display `accessible_colors` have been removed from this branch being outside of acceptance criteria.  This will be moved to a separate issue along with any other work needed to finalize the public preview such as `gh help` entries for `GH_ACCESSIBLE_COLORS` environment variable.

List commands that use ColorScheme.Gray have been updated to use ColorScheme.Muted.
2025-03-31 11:58:30 -04:00
Andy Feller
79f1b07fb1 Implement and fix tests for table headers 2025-03-25 15:29:05 -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
Azeem Sajid
33c30d5bd1 Inconsistent format of examples in help text 2025-02-27 16:26:25 +05:00
Azeem Sajid
8b7fb231ec Remove trailing whitespace 2025-02-13 11:06:27 +05:00
Heath Stewart
446f66070a
Add filtered content output to docs 2024-10-15 14:39:21 -07:00
Heath Stewart
9e00f1e4f2
Resolve PR feedback 2024-10-14 15:08:23 -07:00
Heath Stewart
e9d8092ffc
Don't append remaining text if more matches 2024-10-12 23:17:57 -07:00
Heath Stewart
bddadef574
Highlight matches in table and content
When `--filter` is passed, matches will be highlighted in the existing table. If file names match, the "n file(s)" cell will be highlighted.

When `--include-content` is additionally passed, the file name, description, and/or content will be printed like `search code` with matches highlighted.
2024-10-12 23:17:56 -07:00
Heath Stewart
86f045ef0e
Split all newlines, and output no-color to non-TTY 2024-10-12 23:17:56 -07:00
Heath Stewart
70b14215ec
Print filtered gists similar to code search 2024-10-12 23:17:56 -07:00
Heath Stewart
4eaeda580b
Show progress when filtering
Filtering can take a while, so show progress. This also uncovered a bug
that I wasn't checking if a filter was actually specified, resulting in
a non-nil `opts.Filter`.
2024-10-12 23:17:56 -07:00
Heath Stewart
1615f2c1e1
Simplify description 2024-10-12 23:17:56 -07:00
Tyler McGoffin
b56353dc02
Disallow use of --include-content without --filter 2024-10-12 23:17:55 -07:00
Heath Stewart
73af9f8bd9
Improve help docs
Also changes `--filter` argument to "expression" to coincide with some other commands' help text e.g., `--jq`.
2024-10-12 23:17:55 -07:00
Heath Stewart
34203d7e6c
Refactor filtering into existing gist list
Resolves feedback in issue #9704
2024-10-12 23:17:55 -07:00
Heath Stewart
2fb5687777
Improve performance
Filter as we get results instead of getting them all. This allows us to more easily terminate pagination when opts.Limit is reached.
2024-10-12 23:17:55 -07:00
Heath Stewart
8c6d4c9c52
Add gist search command
Resolves #9704
2024-10-12 23:17:52 -07:00
William Martin
1d38230675
Move config interfaces into gh package (#9060) 2024-05-10 10:39:36 +02:00
Heath Stewart
7738b6187c
Add headers to all tables (#8157) 2023-10-20 11:20:02 +02:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Mislav Marohnić
3fe5026d39
Migrate to tableprinter from go-gh (#6346) 2022-10-17 15:15:39 +02:00
Sam Coe
e7102f9d84
Migrate to go-gh text package (#6236) 2022-09-14 09:23:55 +04:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Roshan Padaki
13342cb272
Don't error on list commands when no results found (#5479)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-04-25 17:55:52 +00:00
Christian Gregg
c5dbf20ed4
Alias list as ls for all commands (#5214)
I always get tripped up whenever trying to list my codespaces, adding
`ls` as an alias to `list` feels natural enough.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-02-17 13:53:42 +01:00
Mislav Marohnić
4a3ef50d2d
Standardize pager output across commands (#5141)
Add pager functionality to the following commands:
- gist list
- pr checks
- release list
- run list
- run view
- secret list
- workflow list
- workflow view

Additionally, normalize error handling when starting the pager has
failed: only print a non-fatal notice to stderr instead of aborting the
whole command.
2022-02-01 08:36:51 +01:00
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
b70b0402eb
Merge pull request #3200 from cli/table-widths
Ensure that table printer always uses all available width in the terminal
2021-03-30 16:54:13 +02:00
Sam
9ec1e21d4c
Default to GHES host if only GHES is authenticated (#3286) 2021-03-30 16:51:00 +02:00
Mislav Marohnić
ed15bebb84 Ensure that table printer fills the full width of the terminal
Sometimes, due to rounding errors, after calculating the width of each
column in a table, the sum of all columns would be shorter that the
total available width in the terminal. This reimplements the elastic
column resizing algorithm to ensure that all available space has been
filled.

As a bonus fix, columns that contain URLs are never truncated.
2021-03-11 19:04:57 +01:00
boonhong
5403a37601 Add interactive select in gist view 2021-02-24 18:38:05 +08:00
Mislav Marohnić
cd2adfeba0 Port listing gists to githubv4 GraphQL client
- Fetching more than 100 gists is now supported
- The GraphQL query name is now `GistList` instead of `ListGists` for
  consistency with other queries
- Avoid fetching unnecessary Files fields
- Gists are now rendered in the order that the API returned them in
- The gist timestamp for machine-readable output is now rendered in
  RFC3339 format instead of in `time.Time.String()` format which is only
  meant for debugging and is not considered stable
- Ensure newlines in gist description are rendered as spaces
2020-10-05 20:33:31 +02:00
Mislav Marohnić
1859728f7e Fix parsing gist list --public/--secret flags
It's not sufficient to use `Changed("public")` to test if a boolean flag
was activated, since the user might have passed `--public=false`.
Instead, check the true value of the flag.

The `--public` and `--secret` flags should be mutually exclusive, so now
if both are activated, `--secret` takes precedence.
2020-10-05 20:27:05 +02:00
Matthew Gleich
f124370154
♻️ Refactor to only pass time in once for test
Signed-off-by: Matthew Gleich <email@mattglei.ch>
2020-10-04 15:02:13 -04:00
Matthew Gleich
d8ef8b836e
🐛 Fix stubs
Signed-off-by: Matthew Gleich <email@mattglei.ch>
2020-10-04 01:57:36 -04:00
Matthew Gleich
89e1ee3217
♻️ Refactor gist list to use graphQL
Signed-off-by: Matthew Gleich <matthewgleich@gmail.com>
2020-09-17 16:27:23 -04:00
vilmibm
2b70e8266a better time stub 2020-09-16 10:57:20 -05:00
vilmibm
4a467864d5 linter appeasement 2020-09-15 15:22:28 -05:00
vilmibm
a61c897e4c show filename if no description 2020-09-15 14:55:55 -05:00
vilmibm
ba5b639be4 finish list tests 2020-09-15 14:33:14 -05:00
vilmibm
9fd87faadc wip tests 2020-09-15 14:15:44 -05:00