Skip to content

Commit 4de4bd7

Browse files
committed
display an action is the default one
Signed-off-by: Yves Brissaud <[email protected]>
1 parent 2f09ef0 commit 4de4bd7

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

internal/commands/root/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func mdAction(rk *runkit.RunKit, action string) string {
258258

259259
s := strings.Builder{}
260260
if act.Desc != "" {
261-
s.WriteString(fmt.Sprintf("`%s`: %s\n", act.ID, act.Desc))
261+
s.WriteString(fmt.Sprintf("`%s`%s: %s\n", act.ID, sugar.If(act.IsDefault(), " (default)", ""), act.Desc))
262262
} else {
263263
s.WriteString(fmt.Sprintf("`%s`\n", act.ID))
264264
}
@@ -299,7 +299,7 @@ func mdActions(rk *runkit.RunKit) string {
299299
} else {
300300
for _, action := range rk.Config.Actions {
301301
if action.Desc != "" {
302-
s.WriteString(fmt.Sprintf(" - `%s`: %s\n", action.ID, action.Desc))
302+
s.WriteString(fmt.Sprintf(" - `%s`%s: %s\n", action.ID, sugar.If(action.IsDefault(), "(default)", ""), action.Desc))
303303
} else {
304304
s.WriteString(fmt.Sprintf(" - `%s`\n", action.ID))
305305
}

runkit/read.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ func Get(ctx context.Context, src string) (*RunKit, error) {
138138
a.DockerfileContent = c
139139
}
140140
}
141+
142+
if config.Default == a.ID {
143+
a.isDefault = true
144+
}
145+
141146
actions = append(actions, a)
142147
}
143148
config.Actions = actions

runkit/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type (
1515
}
1616

1717
Action struct {
18+
isDefault bool
1819
ID string `yaml:"id" json:"id"`
1920
Desc string `yaml:"desc,omitempty" json:"desc,omitempty"`
2021
Type ActionType `yaml:"type" json:"type"`
@@ -55,3 +56,7 @@ const (
5556
ActionTypeRun ActionType = "run"
5657
ActionTypeBuild ActionType = "build"
5758
)
59+
60+
func (a *Action) IsDefault() bool {
61+
return a.isDefault
62+
}

0 commit comments

Comments
 (0)