Skip to content

Consolidate terminal input/output functionality in termstatus.Terminal#5518

Merged
MichaelEischer merged 25 commits into
restic:masterfrom
MichaelEischer:termstatus-everywhere
Oct 3, 2025
Merged

Consolidate terminal input/output functionality in termstatus.Terminal#5518
MichaelEischer merged 25 commits into
restic:masterfrom
MichaelEischer:termstatus-everywhere

Conversation

@MichaelEischer

@MichaelEischer MichaelEischer commented Sep 21, 2025

Copy link
Copy Markdown
Member

What does this PR change? What problem does it solve?

Continue the termstatus refactoring. This PR now centralizes all low-level output related functionality in termstatus.Terminal. This includes all stdin, stdout and stderr related functionality. The termstatus instance is now created in the main() function. This allows replacing globalOptions.stdout and globalOptions.stderr with new termstatus functionality in the course of this PR. In addition, the globalOptions variable is no longer a global variable but passed individually to each command.

Direct os.Stdin, os.Stdout and os.Stderr usage is restricted to global.go and main.go by using the termstatus instance of classical dependency injection. fmt.Print* usages are also cut down to an absolute minimum. Backends now also receive a function to print warnings.

Tests that need a termstatus.Terminal must now use either withCaptureStdout or withTermStatus. Combining both is no longer necessary and possible.

The changes happen in a slightly random order, but I've already spent too many hour reordering the commit and fixing thousands of merge conflicts to clean this up further.

Was the change previously discussed in an issue or on the forum?

Follow up to #5510 .

Checklist

  • I have added tests for all code changes.
  • [ ] I have added documentation for relevant changes (in the manual).
  • [ ] There's a new file in changelog/unreleased/ that describes the changes for our users (see template). I don't expect any notable user visible changes.
  • I'm done! This pull request is ready for review.

@MichaelEischer MichaelEischer changed the title Termstatus everywhere Consolidate terminal input/output functionality in termstatus.Terminal Sep 21, 2025
@MichaelEischer MichaelEischer force-pushed the termstatus-everywhere branch 5 times, most recently from d54ca9e to 1cf09cf Compare September 21, 2025 17:50
@MichaelEischer MichaelEischer marked this pull request as ready for review September 21, 2025 18:17
@greatroar greatroar mentioned this pull request Sep 30, 2025
4 tasks

@MichaelEischer MichaelEischer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant