Skip to content
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

Dogfood term package from go-gh #6421

Merged
merged 8 commits into from Nov 3, 2022
Merged

Dogfood term package from go-gh #6421

merged 8 commits into from Nov 3, 2022

Conversation

mislav
Copy link
Member

@mislav mislav commented Oct 11, 2022

This switches IOStreams to use pkg/term from the go-gh library.

term does not handle most of what IOStreams did previously, so a lot of its logic still stays, but this cleans up overlapping functionality.

TODO:

Fixes #6524

@mislav mislav marked this pull request as ready for review Oct 24, 2022
@mislav mislav requested a review from a team as a code owner Oct 24, 2022
@mislav mislav requested review from vilmibm (assigned from cli/code-reviewers) and removed request for a team Oct 24, 2022
@cliAutomation cliAutomation added this to Needs review 🤔 in The GitHub CLI Oct 24, 2022
samcoe
samcoe approved these changes Oct 31, 2022
Copy link
Member

@samcoe samcoe left a comment

Thanks for doing this work! Left one question comment.

In the future do you invasion more of the iostreams package getting moved over to the term package?

func hasAlternateScreenBuffer(hasTrueColor bool) bool {
// on Windows we just assume that alternate screen buffer is supported if we
// enabled virtual terminal processing, which in turn enables truecolor
return hasTrueColor
Copy link
Member

@samcoe samcoe Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does windows not support os.Getenv("TERM")?

Copy link
Member Author

@mislav mislav Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge, Windows typically doesn't advertise terminal features via the TERM environment variable, but it does expose them programmatically through Console APIs. Hence, if we successfully enabled virtual terminal processing via these APIs, I think we can safely assume that alternate screen buffers are enabled. This is why the check isn't symmetrical with non-Windows platforms.

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Oct 31, 2022
@mislav
Copy link
Member Author

mislav commented Oct 31, 2022

In the future do you invasion more of the iostreams package getting moved over to the term package?

I felt that iostreams was large (had too many responsibilities) and I didn't want to port it to go-gh verbatim; that's why I cherry-picked parts of it that felt "stable" and reusable. Some features that didn't make it:

  • PAGER support
  • Detecting terminal theme: this only makes sense if the extension uses pager and Glamour or our markdown package
  • Loading indicator (spinner) support: this isn't great as it requires manually starting & stopping spinner, which was historically error-prone
  • Alternate screen buffer & clearing screen: this is relatively new to iostreams and we have to still check how successful it is
  • CanPrompt() - only useful after we expose Survey functionality in go-gh
  • ReadUserFile() - too specific
  • TempFile() - too specific

Of all the things listed, I only see pager & spinner support as potential next extractions, but I feel neither are pressing and that they have to be redesigned (code-wise) as they're being ported over.

mislav and others added 4 commits Oct 31, 2022
Fix setting up git credential helper on Windows
Features:
- Support garage.github.com
- Resolve ssh hostname aliases with `ssh -G`
- Correctly measure terminal size when stdout is redirected
@mislav mislav enabled auto-merge Nov 3, 2022
@mislav mislav merged commit 9ec2107 into trunk Nov 3, 2022
10 checks passed
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Nov 3, 2022
@mislav mislav deleted the go-gh-term branch Nov 3, 2022
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

tablerow in templates truncates strings
2 participants