goc/pkg/flag/help.go

21 lines
335 B
Go
Raw Normal View History

2021-04-19 02:18:37 +00:00
package flag
import (
"fmt"
"github.com/spf13/cobra"
)
func printHelp(usage string, cmd *cobra.Command) {
fmt.Println(usage)
flags := cmd.LocalFlags()
globalFlags := cmd.Parent().PersistentFlags()
fmt.Println("Flags:")
fmt.Println(flags.FlagUsages())
fmt.Println("Global Flags:")
fmt.Println(globalFlags.FlagUsages())
}