mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
refactor: remove helpers the new output and prompts left unused
Drop writeDownload, terminal.Require, terminal.Confirm, terminal.Row, terminal.Record and Pulls.FindOpenByHead, which no command calls anymore, and point their tests at the code that replaced them. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
8 files changed
+34
-118
No files matched your search
@@ -19,7 +19,6 @@ import (
|
||||
"gitea.dev/tea/internal/clierr"
|
||||
"gitea.dev/tea/internal/terminal"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// downloadFlags are the destination flags of a download command.
|
||||
@@ -95,19 +94,6 @@ func (a *application) download(cmd *cobra.Command, f downloadFlags, path string,
|
||||
})
|
||||
}
|
||||
|
||||
func writeDownload(cmd *cobra.Command, body io.Reader, output string) error {
|
||||
if output == "" || output == "-" {
|
||||
return writeTerminalSafe(cmd.OutOrStdout(), isTerminal(cmd.OutOrStdout()), body)
|
||||
}
|
||||
return publish(cmd, output, false, false, func(destination io.Writer) error { _, err := io.Copy(destination, body); return err })
|
||||
}
|
||||
|
||||
// isTerminal reports whether w is a terminal, for writers without injected stream capabilities.
|
||||
func isTerminal(w io.Writer) bool {
|
||||
file, ok := w.(*os.File)
|
||||
return ok && term.IsTerminal(int(file.Fd()))
|
||||
}
|
||||
|
||||
// binarySniffLength is how much of a download decides whether it is text.
|
||||
const binarySniffLength = 8 << 10
|
||||
|
||||
|
||||
Reference in new issue
Block a user