mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 13:43:47 +03:00
258bc82b69
* cmd: migrate to spf13/cobra * add `manpage` command * limit Caddy tagline to root `help` only * hard-code the manpage section to 8
33 lines
751 B
Go
33 lines
751 B
Go
package caddycmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "caddy",
|
|
}
|
|
|
|
const docsHeader = "{{if not .HasParent}} Caddy is an extensible server platform.\n\n{{end}}"
|
|
const fullDocsFooter = `Full documentation is available at:
|
|
https://caddyserver.com/docs/command-line
|
|
`
|
|
|
|
func init() {
|
|
rootCmd.SetHelpTemplate(docsHeader + rootCmd.HelpTemplate() + "\n" + fullDocsFooter)
|
|
}
|
|
|
|
func caddyCmdToCoral(caddyCmd Command) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: caddyCmd.Name,
|
|
Short: caddyCmd.Short,
|
|
Long: caddyCmd.Long,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
fls := cmd.Flags()
|
|
_, err := caddyCmd.Func(Flags{fls})
|
|
return err
|
|
},
|
|
}
|
|
cmd.Flags().AddGoFlagSet(caddyCmd.Flags)
|
|
return cmd
|
|
}
|