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() defer env.Close()
cfg := engine.LoadConfig(env) cfg := engine.LoadConfig(env)
ansi := &color.Ansi{} ansi := &color.Ansi{}
ansi.InitPlain(shell.PLAIN) ansi.InitPlain()
writerColors := cfg.MakeColors(env) writerColors := cfg.MakeColors(env)
writer := &color.AnsiWriter{ writer := &color.AnsiWriter{
Ansi: ansi, Ansi: ansi,

View file

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

View file

@ -68,7 +68,7 @@ var printCmd = &cobra.Command{
ansi.Init(env.Shell()) ansi.Init(env.Shell())
var writer color.Writer var writer color.Writer
if plain { if plain {
ansi.InitPlain(env.Shell()) ansi.InitPlain()
writer = &color.PlainWriter{ writer = &color.PlainWriter{
Ansi: ansi, 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) a.Init(shell.PLAIN)
} }

View file

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

View file

@ -61,7 +61,7 @@ func TestGetTitle(t *testing.T) {
Folder: "vagrant", Folder: "vagrant",
}) })
ansi := &color.Ansi{} ansi := &color.Ansi{}
ansi.InitPlain(tc.ShellName) ansi.InitPlain()
ct := &Title{ ct := &Title{
Env: env, Env: env,
Ansi: ansi, Ansi: ansi,
@ -116,7 +116,7 @@ func TestGetConsoleTitleIfGethostnameReturnsError(t *testing.T) {
HostName: "", HostName: "",
}) })
ansi := &color.Ansi{} ansi := &color.Ansi{}
ansi.InitPlain(tc.ShellName) ansi.InitPlain()
ct := &Title{ ct := &Title{
Env: env, Env: env,
Ansi: ansi, 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) { func (b *Block) InitPlain(env environment.Environment, config *Config) {
b.ansi = &color.Ansi{} b.ansi = &color.Ansi{}
b.ansi.InitPlain(env.Shell()) b.ansi.InitPlain()
b.writer = &color.AnsiWriter{ b.writer = &color.AnsiWriter{
Ansi: b.ansi, Ansi: b.ansi,
TerminalBackground: shell.ConsoleBackgroundColor(env, config.TerminalBackground), TerminalBackground: shell.ConsoleBackgroundColor(env, config.TerminalBackground),

View file

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

View file

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