40
cli/run.go
40
cli/run.go
@ -47,6 +47,29 @@ Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
|
||||
|
||||
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
|
||||
`)
|
||||
|
||||
helpCmd = &cobra.Command{
|
||||
Use: i18n.G("help [command]"),
|
||||
// translators: Short description for `help` command
|
||||
Short: i18n.G("Help about any command"),
|
||||
Long: i18n.G(`Help provides help for any command in the application.
|
||||
Simply type abra help [path to command] for full details.`),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
cmd, _, e := c.Root().Find(args)
|
||||
if cmd == nil || e != nil {
|
||||
c.Print(i18n.G("unknown help topic %#q\n", args))
|
||||
if err := c.Root().Usage(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
cmd.InitDefaultHelpFlag()
|
||||
cmd.InitDefaultVersionFlag()
|
||||
if err := cmd.Help(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func Run(version, commit string) {
|
||||
@ -122,6 +145,7 @@ Config:
|
||||
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
rootCmd.SetUsageTemplate(usageTemplate)
|
||||
rootCmd.SetHelpCommand(helpCmd)
|
||||
|
||||
// translators: `abra man` aliases. use a comma separated list of aliases
|
||||
// with no spaces in between
|
||||
@ -185,6 +209,22 @@ Config:
|
||||
i18n.G("prefer offline & filesystem access"),
|
||||
)
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(
|
||||
&internal.Help,
|
||||
i18n.G("help"),
|
||||
i18n.G("h"),
|
||||
false,
|
||||
i18n.G("help for abra"),
|
||||
)
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(
|
||||
&internal.Version,
|
||||
i18n.G("version"),
|
||||
i18n.G("v"),
|
||||
false,
|
||||
i18n.G("version for abra"),
|
||||
)
|
||||
|
||||
catalogue.CatalogueCommand.AddCommand(
|
||||
catalogue.CatalogueGenerateCommand,
|
||||
catalogue.CatalogueSyncCommand,
|
||||
|
Reference in New Issue
Block a user