Skip to content

Commit 535041d

Browse files
committed
Use as the canonical subcommand
1 parent adb5ccc commit 535041d

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

internal/carvel/baker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ var _ = Describe("Carvel Baker", func() {
477477

478478
publishChecksum := fileChecksum(publishTile)
479479

480-
// Simulate `kiln carvel rebake`: BakeFromLockfile + KilnBake
480+
// Simulate `kiln carvel re-bake`: BakeFromLockfile + KilnBake
481481
rebakeBaker := NewBaker()
482482
rebakeBaker.SetWriter(GinkgoWriter)
483483
err = rebakeBaker.BakeFromLockfile(inputPath, lockfilePath)

internal/commands/carvel.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ type Carvel struct {
1414
outLogger *log.Logger
1515
errLogger *log.Logger
1616
commands jhanda.CommandSet
17+
aliases map[string]bool
1718
}
1819

1920
func NewCarvel(outLogger, errLogger *log.Logger) Carvel {
2021
c := Carvel{
2122
outLogger: outLogger,
2223
errLogger: errLogger,
2324
commands: jhanda.CommandSet{},
25+
aliases: map[string]bool{},
2426
}
2527

2628
// Register subcommands
2729
c.commands["bake"] = NewCarvelBake(outLogger, errLogger)
2830
c.commands["upload"] = NewCarvelUpload(outLogger, errLogger)
2931
c.commands["publish"] = NewCarvelPublish(outLogger, errLogger)
30-
c.commands["rebake"] = NewCarvelReBake(outLogger, errLogger)
32+
c.commands["re-bake"] = NewCarvelReBake(outLogger, errLogger)
33+
34+
// Aliases (hidden from help output)
35+
c.commands["rebake"] = c.commands["re-bake"]
36+
c.aliases["rebake"] = true
3137

3238
return c
3339
}
@@ -59,14 +65,16 @@ func (c Carvel) Execute(args []string) error {
5965
}
6066

6167
func (c Carvel) Usage() jhanda.Usage {
62-
// Build subcommand list for the description
6368
var subcommandList strings.Builder
6469
subcommandList.WriteString("Commands for working with Carvel/Kubernetes tiles.\n\n")
6570
subcommandList.WriteString("Subcommands:\n")
6671

6772
var names []string
6873
var length int
6974
for name := range c.commands {
75+
if c.aliases[name] {
76+
continue
77+
}
7078
names = append(names, name)
7179
if len(name) > length {
7280
length = len(name)
@@ -95,6 +103,9 @@ func (c Carvel) printHelp() error {
95103
)
96104

97105
for name := range c.commands {
106+
if c.aliases[name] {
107+
continue
108+
}
98109
names = append(names, name)
99110
if len(name) > length {
100111
length = len(name)

internal/commands/carvel_publish.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (c CarvelPublish) Execute(args []string) error {
144144

145145
func (c CarvelPublish) Usage() jhanda.Usage {
146146
return jhanda.Usage{
147-
Description: "Publishes a Carvel/Kubernetes tile as a .pivotal file using the cached BOSH release from Kilnfile.lock. Run 'kiln carvel upload' first to build and cache the release. When --final is specified, creates a bake record that can be used with 'kiln carvel rebake' for reproducible builds.",
147+
Description: "Publishes a Carvel/Kubernetes tile as a .pivotal file using the cached BOSH release from Kilnfile.lock. Run 'kiln carvel upload' first to build and cache the release. When --final is specified, creates a bake record that can be used with 'kiln carvel re-bake' for reproducible builds.",
148148
ShortDescription: "publishes a Carvel/Kubernetes tile",
149149
Flags: c.Options,
150150
}

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func main() {
7676
bakeCommand.KilnVersion = version
7777
commandSet["bake"] = bakeCommand
7878
commandSet["re-bake"] = commands.NewReBake(bakeCommand)
79+
commandSet["rebake"] = commandSet["re-bake"]
7980

8081
commandSet["test"] = commands.NewTileTest()
8182
commandSet["help"] = commands.NewHelp(os.Stdout, globalFlagsUsage, commandSet)

0 commit comments

Comments
 (0)