Commit graph

23 commits

Author SHA1 Message Date
Sam Coe
e7102f9d84
Migrate to go-gh text package (#6236) 2022-09-14 09:23:55 +04:00
Roshan Padaki
51301f8782
Fix table printer crashing in narrow terminals (#5449)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-04-13 14:57:41 +00:00
nate smith
f22c325ea4 gh status 2022-03-28 11:53:13 -05:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Heath Stewart
e2973453b5
Add helper template functions for rendering tables (#3519)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-08-23 21:00:25 +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
Nate Smith
126b498e9f
Actions Support Phase 1 (#2923)
* Implement first round of support for GitHub Actions

This commit adds:

gh actions
gh run list
gh run view
gh job view

as part of our first round of actions support. These commands are
unlisted and considered in beta.

* review feedback

* tests for exit status on job view

* spinner tracks io itself

* review feedback

* fix PR matching

* enable pager for job log viewing

* add more colorf functions

* add AnnotationSymbol

* hide job, run

* do not add method to api.Client

* remove useless cargo coded copypasta
2021-03-16 13:59:34 -07: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
Mislav Marohnić
82661c197e Isolate pr list command 2020-08-04 18:38:06 +02:00
vilmibm
36ade42ba3 scriptability improvements: issue commands
This commit is part of work to make gh more scriptable. It includes both
some general purpose helpers towards this goal as well as improvements
to the issue commands. Other commands will follow.

- Adds `utils/terminal.go` for finding out about gh's execution environment
- introduces `stubTerminal` for either faking being attached to a tty or not during tests
- updates issue commands to behave better when not attached to a tty:
  - issue list doesn't print fuzzy dates
  - issue list doesn't print header
  - issue list prints state explicitly
  - issue create no longer hangs
  - issue create fails with clear error unless both -t and -b are specified
  - issue view prints raw issue body
  - issue view prints metadata in a consistent, linewise format
2020-07-14 12:30:53 -05:00
Mislav Marohnić
734497a8d8
Code fixes informed by golangci-lint failures (#738) 2020-04-03 16:33:34 +02:00
Dasio
9289ab99f2 Use var syntax when empty struct is initialized 2020-02-24 22:33:22 +01:00
Mislav Marohnić
9c2efd6c1c Extract reusable IsTerminal() 2020-02-21 12:46:21 +01:00
Mislav Marohnić
4c3e498021 Fix column alignment and truncation for Eastern Asian languages
- Ensure that text is never truncated mid-character, which would result
  in garbled text

- Ensure that columns in `issue/pr list` output align properly
2020-02-20 18:52:17 +01:00
Mislav Marohnić
61ff5d73bd Fix crash in issue/pr list for narrow terminals
If the available column width is smaller than 3, don't try to truncate
with ellipsis (`...`). Instead, just truncate to available width.
2020-02-18 20:03:09 +01:00
Mislav Marohnić
b6fa88337d Ensure that commands print to a colorable output
If a command does `fmt.Print(...)` for output that contains ANSI color
codes, this not safe on Windows. We have to ensure that we always use
the `fmt.Fprint*` family of functions with a writer that was transformed
using `utils.NewColorable()`.
2019-11-27 20:51:51 +01:00
Mislav Marohnić
4148cf76b9 Merge remote-tracking branch 'origin' into win-ansi-color 2019-11-27 20:08:00 +01:00
Mislav Marohnić
4be04aded3 Fix ANSI color output on Windows 2019-11-27 15:43:28 +01:00
Mislav Marohnić
7d904fdef7 Fix detecting terminal under Git Bash on Windows 2019-11-27 15:31:37 +01:00
Mislav Marohnić
97a6dc494b Redesign TablePrinter to avoid SetContentWidth / FitColumns steps
The API is now:
- AddField;
- EndRow;
- Render.
2019-11-20 13:29:27 +01:00
Mislav Marohnić
2022f8e74b Avoid widening table columns that already fit 2019-11-20 12:30:24 +01:00
Mislav Marohnić
9fc80a1f8a Fix crash with empty table 2019-11-20 12:18:50 +01:00
Mislav Marohnić
f30e973b9d Extract generic row printer that adjusts itself for receiving terminal
This makes the approach from `pr list` reusable across other commands
that may benefit from table-based output, e.g. `issue list` or `pr status`

The idea is: instantiate a printer, connect it to stdout, feed it some
data, and it does the rest: colored, truncated column output that fits
into a terminal, or tab-delimited output (no color, no truncation) for
scripts.
2019-11-15 19:19:41 +01:00