github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/docs/common/helputils.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/codegangsta/cli"
     6  	"strings"
     7  )
     8  
     9  func CreateUsage(command string, name string, commands []string) string {
    10  	return "\nName:\n\t" + "jfrog " + command + " - " + name + "\n\nUsage:\n\t" + strings.Join(commands[:], "\n\t") + "\n"
    11  }
    12  
    13  func CreateEnvVars(envVars ...string) string {
    14  	var s []string
    15  	for _, envVar := range envVars {
    16  		s = append(s, envVar)
    17  	}
    18  	s = append(s, GlobalEnvVars)
    19  	return strings.Join(s[:], "\n\n")
    20  }
    21  
    22  func CreateBashCompletionFunc(extraCommands ...string) cli.BashCompleteFunc {
    23  	return func(ctx *cli.Context) {
    24  		for _, command := range extraCommands {
    25  			fmt.Println(command)
    26  		}
    27  		flagNames := append(ctx.FlagNames(), "help")
    28  		for _, flagName := range flagNames {
    29  			fmt.Println("--" + flagName)
    30  		}
    31  	}
    32  }