refactor: remove shell name from plain init

This commit is contained in:
Jan De Dobbeleer 2022-06-12 19:36:49 +02:00 committed by Jan De Dobbeleer
parent 820e28c85c
commit 992add9a78
9 changed files with 10 additions and 11 deletions

View file

@ -58,7 +58,7 @@ Exports the config to an image file using customized output options.`,
defer env.Close()
cfg := engine.LoadConfig(env)
ansi := &color.Ansi{}
ansi.InitPlain(shell.PLAIN)
ansi.InitPlain()
writerColors := cfg.MakeColors(env)
writer := &color.AnsiWriter{
Ansi: ansi,

View file

@ -31,7 +31,7 @@ var debugCmd = &cobra.Command{
defer env.Close()
cfg := engine.LoadConfig(env)
ansi := &color.Ansi{}
ansi.InitPlain(shell.PLAIN)
ansi.InitPlain()
writerColors := cfg.MakeColors(env)
writer := &color.AnsiWriter{
Ansi: ansi,

View file

@ -68,7 +68,7 @@ var printCmd = &cobra.Command{
ansi.Init(env.Shell())
var writer color.Writer
if plain {
ansi.InitPlain(env.Shell())
ansi.InitPlain()
writer = &color.PlainWriter{
Ansi: ansi,
}

View file

@ -128,7 +128,7 @@ func (a *Ansi) Init(shellName string) {
}
}
func (a *Ansi) InitPlain(shellName string) {
func (a *Ansi) InitPlain() {
a.Init(shell.PLAIN)
}

View file

@ -80,7 +80,7 @@ func TestFormatText(t *testing.T) {
}
for _, tc := range cases {
a := Ansi{}
a.InitPlain(shell.PLAIN)
a.InitPlain()
formattedText := a.formatText(tc.Text)
assert.Equal(t, tc.Expected, formattedText, tc.Case)
}

View file

@ -61,7 +61,7 @@ func TestGetTitle(t *testing.T) {
Folder: "vagrant",
})
ansi := &color.Ansi{}
ansi.InitPlain(tc.ShellName)
ansi.InitPlain()
ct := &Title{
Env: env,
Ansi: ansi,
@ -116,7 +116,7 @@ func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
HostName: "",
})
ansi := &color.Ansi{}
ansi.InitPlain(tc.ShellName)
ansi.InitPlain()
ct := &Title{
Env: env,
Ansi: ansi,

View file

@ -53,7 +53,7 @@ func (b *Block) Init(env environment.Environment, writer color.Writer, ansi *col
func (b *Block) InitPlain(env environment.Environment, config *Config) {
b.ansi = &color.Ansi{}
b.ansi.InitPlain(env.Shell())
b.ansi.InitPlain()
b.writer = &color.AnsiWriter{
Ansi: b.ansi,
TerminalBackground: shell.ConsoleBackgroundColor(env, config.TerminalBackground),

View file

@ -58,7 +58,7 @@ func engineRender() {
defer testClearDefaultConfig()
ansi := &color.Ansi{}
ansi.InitPlain(env.Shell())
ansi.InitPlain()
writerColors := cfg.MakeColors(env)
writer := &color.AnsiWriter{
Ansi: ansi,

View file

@ -3,7 +3,6 @@ package engine
import (
"io/ioutil"
"oh-my-posh/color"
"oh-my-posh/shell"
"os"
"path/filepath"
"testing"
@ -33,7 +32,7 @@ func runImageTest(config, content string) (string, error) {
}
defer os.Remove(file.Name())
ansi := &color.Ansi{}
ansi.InitPlain(shell.PLAIN)
ansi.InitPlain()
image := &ImageRenderer{
AnsiString: content,
Ansi: ansi,