Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Dec 2, 2024
1 parent 1743b02 commit 829d23f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/buger/jsonparser v1.1.1
github.com/creack/pty v1.1.24
github.com/essentialkaos/check v1.4.1
github.com/essentialkaos/ek/v13 v13.13.1
github.com/essentialkaos/ek/v13 v13.14.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/essentialkaos/check v1.4.1 h1:SuxXzrbokPGTPWxGRnzy0hXvtb44mtVrdNxgPa1
github.com/essentialkaos/check v1.4.1/go.mod h1:xQOYwFvnxfVZyt5Qvjoa1SxcRqu5VyP77pgALr3iu+M=
github.com/essentialkaos/depsy v1.3.1 h1:00k9QcMsdPM4IzDaEFHsTHBD/zoM0oxtB5+dMUwbQa8=
github.com/essentialkaos/depsy v1.3.1/go.mod h1:B5+7Jhv2a2RacOAxIKU2OeJp9QfZjwIpEEPI5X7auWM=
github.com/essentialkaos/ek/v13 v13.13.1 h1:JuBlzEEzWDvrNVW+goKUTG+2eB+fVNf/RY0WhGoY3Co=
github.com/essentialkaos/ek/v13 v13.13.1/go.mod h1:GAoS44v5gtd3Yc1qqfgXsaJNoC0dMw1ueW5Fc9TTHUg=
github.com/essentialkaos/ek/v13 v13.14.0 h1:kBpA6r5wZxi09ND5vmlzpe9kvjfWSJ4AywBJM8Oq1ME=
github.com/essentialkaos/ek/v13 v13.14.0/go.mod h1:GAoS44v5gtd3Yc1qqfgXsaJNoC0dMw1ueW5Fc9TTHUg=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
24 changes: 12 additions & 12 deletions render/renderer_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ func (rr *TerminalRenderer) CommandSkipped(c *recipe.Command, isLast bool) {
fmtc.NewLine()

if fmtc.DisableColors {
fmtc.Printf(" [SKIPPED] %s\n", info)
fmtc.Printfn(" [SKIPPED] %s", info)
} else {
fmtc.Printf(" {s-}%s{!}\n", info)
fmtc.Printfn(" {s-}%s{!}", info)
}
}

// CommandFailed prints info about failed command
func (rr *TerminalRenderer) CommandFailed(c *recipe.Command, err error) {
fmtc.NewLine()
fmtc.Printf(" {r}%v{!}\n", err)
fmtc.Printfn(" {r}%v{!}", err)
}

// CommandFailed prints info about executed command
Expand Down Expand Up @@ -130,7 +130,7 @@ func (rr *TerminalRenderer) ActionFailed(a *recipe.Action, err error) {
fmtc.NewLine()
}

fmtc.Printf(" {r}%v{!}\n", err)
fmtc.Printfn(" {r}%v{!}", err)
}

// ActionDone prints info about successfully finished action
Expand Down Expand Up @@ -171,19 +171,19 @@ func (rr *TerminalRenderer) Result(passes, fails, skips int) {
fmtutil.Separator(false, "RESULTS")

if passes == 0 {
fmtc.Printf(" {*}Passed:{!} {r}%d{!}\n", passes)
fmtc.Printfn(" {*}Passed:{!} {r}%d{!}", passes)
} else {
fmtc.Printf(" {*}Passed:{!} {g}%d{!}\n", passes)
fmtc.Printfn(" {*}Passed:{!} {g}%d{!}", passes)
}

if fails == 0 {
fmtc.Printf(" {*}Failed:{!} {g}%d{!}\n", fails)
fmtc.Printfn(" {*}Failed:{!} {g}%d{!}", fails)
} else {
fmtc.Printf(" {*}Failed:{!} {r}%d{!}\n", fails)
fmtc.Printfn(" {*}Failed:{!} {r}%d{!}", fails)
}

if skips != 0 {
fmtc.Printf(" {*}Skipped:{!} {s}%d{!}\n", skips)
fmtc.Printfn(" {*}Skipped:{!} {s}%d{!}", skips)
}

d := rr.formatDuration(time.Since(rr.start), true)
Expand All @@ -205,8 +205,8 @@ func (rr *TerminalRenderer) printRecipeInfo(r *recipe.Recipe) {

fmtutil.Separator(false, "RECIPE")

fmtc.Printf(" {*}%-15s{!} %s\n", "Recipe file:", recipeFile)
fmtc.Printf(" {*}%-15s{!} %s\n", "Working dir:", workingDir)
fmtc.Printfn(" {*}%-15s{!} %s", "Recipe file:", recipeFile)
fmtc.Printfn(" {*}%-15s{!} %s", "Working dir:", workingDir)

rr.printOptionFlag("Unsafe actions", r.UnsafeActions)
rr.printOptionFlag("Require root", r.RequireRoot)
Expand Down Expand Up @@ -248,7 +248,7 @@ func (rr *TerminalRenderer) formatDuration(d time.Duration, withMS bool) string
// renderTmpMessage prints temporary message limited by window size
func (rr *TerminalRenderer) renderTmpMessage(f string, a ...interface{}) {
if isCI {
fmtc.Printf(f+"\n", a...)
fmtc.Printfn(f, a...)
return
}

Expand Down

0 comments on commit 829d23f

Please sign in to comment.