Skip to content

Commit

Permalink
Merge pull request #500 from roots/make-vm-commands-non-experimental
Browse files Browse the repository at this point in the history
`vm` commands are now recommended over `up`/`down`
  • Loading branch information
swalkinshaw authored Dec 30, 2024
2 parents 54a3d2d + 1aa11bb commit b19fc2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ import (
"github.com/mitchellh/cli"
)

func experimentalCommandHelpFunc(app string, f cli.HelpFunc) cli.HelpFunc {
func deprecatedCommandHelpFunc(commandNames []string, f cli.HelpFunc) cli.HelpFunc {
return func(commands map[string]cli.CommandFactory) string {
var buf bytes.Buffer
if len(experimentalCommands) > 0 {
buf.WriteString("\n\nExperimental commands:\n")
if len(commandNames) > 0 {
buf.WriteString("\n\nDeprecated commands:\n")
}

maxKeyLen := 0
keys := make([]string, 0, len(experimentalCommands))
keys := make([]string, 0, len(commandNames))
filteredCommands := make(map[string]cli.CommandFactory)

for key, command := range commands {
for _, experimentalKey := range experimentalCommands {
if key != experimentalKey {
for _, deprecatedKey := range commandNames {
if key != deprecatedKey {
filteredCommands[key] = command
}
}
}

for _, key := range experimentalCommands {
for _, key := range commandNames {
if len(key) > maxKeyLen {
maxKeyLen = len(key)
}
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
// To be replaced by goreleaser build flags.
var version = "canary"
var updaterRepo = ""
var experimentalCommands = []string{
"vm",
var deprecatedCommands = []string{
"down",
"up",
}

func main() {
Expand Down Expand Up @@ -212,7 +213,7 @@ func main() {
}

c.HiddenCommands = []string{"venv", "venv hook"}
c.HelpFunc = experimentalCommandHelpFunc(c.Name, cli.BasicHelpFunc("trellis"))
c.HelpFunc = deprecatedCommandHelpFunc(deprecatedCommands, cli.BasicHelpFunc("trellis"))

if trellis.CliConfig.LoadPlugins {
pluginPaths := filepath.SplitList(os.Getenv("PATH"))
Expand Down

0 comments on commit b19fc2f

Please sign in to comment.