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
Contributor

@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 October 24, 2022 15:20
@mislav mislav requested a review from a team as a code owner October 24, 2022 15:20
@mislav mislav requested review from vilmibm and removed request for a team October 24, 2022 15:20
@cliAutomation cliAutomation added this to Needs review 🤔 in The GitHub CLI Oct 24, 2022
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

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
Contributor

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
Contributor Author

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
Contributor 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 October 31, 2022 15:33
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 November 3, 2022 11:53
@mislav mislav merged commit 9ec2107 into trunk Nov 3, 2022
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 November 3, 2022 12:02
@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
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

tablerow in templates truncates strings
2 participants