Skip to content

Commit 2ffc18f

Browse files
committed
chore: minor refactor
Signed-off-by: Abiola Ibrahim <[email protected]>
1 parent c441c26 commit 2ffc18f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cli/chain.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// CtxKeyQuiet is the context key to mute the chain.
13-
var CtxKeyQuiet = struct{ quiet bool }{quiet: true}
13+
var CtxKeyQuiet = struct{ key string }{key: "quiet"}
1414

1515
// errNonFatal is a non fatal error
1616
type errNonFatal struct {
@@ -77,6 +77,8 @@ type ActiveCommandChain struct {
7777
funcs []cFunc
7878
lastStage string
7979
log *log.Entry
80+
81+
executing bool
8082
}
8183

8284
// Logger returns the logger for the command chain.
@@ -89,6 +91,10 @@ func (a *ActiveCommandChain) Add(f func() error) {
8991

9092
// Stage sets the current stage of the runner.
9193
func (a *ActiveCommandChain) Stage(s string) {
94+
if a.executing {
95+
a.log.Println(s, "...")
96+
return
97+
}
9298
a.funcs = append(a.funcs, cFunc{s: s})
9399
}
94100

@@ -101,7 +107,10 @@ func (a *ActiveCommandChain) Stagef(format string, s ...interface{}) {
101107
// Exec executes the command chain.
102108
// The first errored function terminates the chain and the
103109
// error is returned. Otherwise, returns nil.
104-
func (a ActiveCommandChain) Exec() error {
110+
func (a *ActiveCommandChain) Exec() error {
111+
a.executing = true
112+
defer func() { a.executing = false }()
113+
105114
for _, f := range a.funcs {
106115
if f.f == nil {
107116
if f.s != "" {

0 commit comments

Comments
 (0)