mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-25 19:14:50 -08:00
feat(upgrade): add terminal progress indication
This commit is contained in:
parent
7c7bd14a45
commit
be8954867f
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/engine"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/platform"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/terminal"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/upgrade"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -37,6 +38,11 @@ var upgradeCmd = &cobra.Command{
|
|||
env.Init()
|
||||
defer env.Close()
|
||||
|
||||
terminal.Init(env.Shell())
|
||||
fmt.Print(terminal.StartProgress())
|
||||
|
||||
defer fmt.Print(terminal.StopProgress())
|
||||
|
||||
if force {
|
||||
upgrade.Run(env)
|
||||
return
|
||||
|
|
|
@ -134,6 +134,9 @@ const (
|
|||
hyperLinkText = "<TEXT>"
|
||||
hyperLinkTextEnd = "</TEXT>"
|
||||
|
||||
startProgress = "\x1b]9;4;3;0\x07"
|
||||
endProgress = "\x1b]9;4;0;0\x07"
|
||||
|
||||
WindowsTerminal = "Windows Terminal"
|
||||
Warp = "WarpTerminal"
|
||||
ITerm = "iTerm.app"
|
||||
|
@ -360,6 +363,22 @@ func LineBreak() string {
|
|||
return cr + lf
|
||||
}
|
||||
|
||||
func StartProgress() string {
|
||||
if Program != WindowsTerminal {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf(formats.escape, startProgress)
|
||||
}
|
||||
|
||||
func StopProgress() string {
|
||||
if Program != WindowsTerminal {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf(formats.escape, endProgress)
|
||||
}
|
||||
|
||||
func Write(background, foreground, text string) {
|
||||
if len(text) == 0 {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue