github.com/jfrog/jfrog-cli-core/v2@v2.51.0/docs/common/helputils.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
     6  	"github.com/urfave/cli"
     7  )
     8  
     9  func CreateUsage(command string, name string, commands []string) string {
    10  	var usage string
    11  	for _, cmd := range commands {
    12  		usage += coreutils.GetCliExecutableName() + " " + cmd + "\n\t"
    13  	}
    14  	return "\nName:\n\t" + coreutils.GetCliExecutableName() + " " + command + " - " + name + "\n\nUsage:\n\t" + usage
    15  }
    16  
    17  func CreateBashCompletionFunc(extraCommands ...string) cli.BashCompleteFunc {
    18  	return func(ctx *cli.Context) {
    19  		for _, command := range extraCommands {
    20  			fmt.Println(command)
    21  		}
    22  		flagNames := append(ctx.FlagNames(), "help")
    23  		for _, flagName := range flagNames {
    24  			fmt.Println("--" + flagName)
    25  		}
    26  	}
    27  }