github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/internal/pcsinit/pcsinit.go (about) 1 // Package pcsinit 初始化配置包 2 package pcsinit 3 4 import ( 5 "fmt" 6 "github.com/urfave/cli" 7 _ "unsafe" // for go:linkname 8 ) 9 10 //go:linkname helpCommand1 github.com/fzfile/BaiduPCS-Go/vendor/github.com/urfave/cli.helpCommand 11 //go:linkname helpCommand2 github.com/urfave/cli.helpCommand 12 var ( 13 helpCommand1 cli.Command 14 helpCommand2 cli.Command 15 ) 16 17 func init() { 18 cli.AppHelpTemplate = `---- 19 {{.Name}}{{if .Usage}} - {{.Usage}}{{end}} 20 21 USAGE: 22 {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}} 23 24 VERSION: 25 {{.Version}}{{end}}{{end}}{{if .Description}} 26 27 DESCRIPTION: 28 {{.Description}}{{end}}{{if len .Authors}} 29 30 AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: 31 {{range $index, $author := .Authors}}{{if $index}} 32 {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}} 33 34 COMMANDS:{{range .VisibleCategories}}{{if .Name}} 35 {{.Name}}:{{end}}{{range .VisibleCommands}} 36 {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} 37 38 GLOBAL OPTIONS: 39 {{range $index, $option := .VisibleFlags}}{{if $index}} 40 {{end}}{{$option}}{{end}}{{end}}{{if .Copyright}} 41 42 COPYRIGHT: 43 {{.Copyright}}{{end}} 44 ` 45 46 cli.CommandHelpTemplate = `---- 47 {{.HelpName}} - {{.Usage}} 48 49 USAGE: 50 {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}} 51 52 CATEGORY: 53 {{.Category}}{{end}}{{if .Description}} 54 55 DESCRIPTION: 56 {{.Description}}{{end}}{{if .VisibleFlags}} 57 58 OPTIONS: 59 {{range .VisibleFlags}}{{.}} 60 {{end}}{{end}} 61 ` 62 63 cli.SubcommandHelpTemplate = `---- 64 {{.HelpName}} - {{.Usage}} 65 66 USAGE: 67 {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}} 68 69 DESCRIPTION: 70 {{.Description}}{{end}} 71 72 COMMANDS:{{range .VisibleCategories}}{{if .Name}} 73 {{.Name}}:{{end}}{{range .VisibleCommands}} 74 {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}} 75 {{end}}{{if .VisibleFlags}} 76 OPTIONS: 77 {{range .VisibleFlags}}{{.}} 78 {{end}}{{end}} 79 ` 80 81 helpCommand1.Aliases = append(helpCommand1.Aliases, "?", "?") 82 helpCommand1.Action = func(c *cli.Context) error { 83 args := c.Args() 84 if args.Present() { 85 err := cli.ShowCommandHelp(c, args.First()) 86 if err != nil { 87 fmt.Printf("%s\n", err) 88 } 89 return nil 90 } 91 92 cli.ShowAppHelp(c) 93 return nil 94 } 95 96 helpCommand2.Aliases = helpCommand1.Aliases 97 helpCommand2.Action = helpCommand1.Action 98 }