summaryrefslogtreecommitdiff
path: root/cmd/commandfuncs.go
diff options
context:
space:
mode:
authorMohammed Al Sahaf <msaa1990@gmail.com>2022-08-31 01:38:38 +0300
committerGitHub <noreply@github.com>2022-08-30 22:38:38 +0000
commit258bc82b69ccb0f514fc62ec8ecd7273458ab2e4 (patch)
tree201b76cd74ce0809f6b3061af4c145759a6e483f /cmd/commandfuncs.go
parent8cb3cf540c2d083721a1717b9ddf2657b7eb5102 (diff)
cmd: Migrate to `spf13/cobra`, remove single-dash arg support (#4565)
* cmd: migrate to spf13/cobra * add `manpage` command * limit Caddy tagline to root `help` only * hard-code the manpage section to 8
Diffstat (limited to 'cmd/commandfuncs.go')
-rw-r--r--cmd/commandfuncs.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 67015f7..874cc6f 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -29,7 +29,6 @@ import (
"os/exec"
"runtime"
"runtime/debug"
- "sort"
"strings"
"github.com/aryann/difflib"
@@ -580,70 +579,6 @@ func cmdFmt(fl Flags) (int, error) {
return caddy.ExitCodeSuccess, nil
}
-func cmdHelp(fl Flags) (int, error) {
- const fullDocs = `Full documentation is available at:
-https://caddyserver.com/docs/command-line`
-
- args := fl.Args()
- if len(args) == 0 {
- s := `Caddy is an extensible server platform.
-
-usage:
- caddy <command> [<args...>]
-
-commands:
-`
- keys := make([]string, 0, len(commands))
- for k := range commands {
- keys = append(keys, k)
- }
- sort.Strings(keys)
- for _, k := range keys {
- cmd := commands[k]
- short := strings.TrimSuffix(cmd.Short, ".")
- s += fmt.Sprintf(" %-15s %s\n", cmd.Name, short)
- }
-
- s += "\nUse 'caddy help <command>' for more information about a command.\n"
- s += "\n" + fullDocs + "\n"
-
- fmt.Print(s)
-
- return caddy.ExitCodeSuccess, nil
- } else if len(args) > 1 {
- return caddy.ExitCodeFailedStartup, fmt.Errorf("can only give help with one command")
- }
-
- subcommand, ok := commands[args[0]]
- if !ok {
- return caddy.ExitCodeFailedStartup, fmt.Errorf("unknown command: %s", args[0])
- }
-
- helpText := strings.TrimSpace(subcommand.Long)
- if helpText == "" {
- helpText = subcommand.Short
- if !strings.HasSuffix(helpText, ".") {
- helpText += "."
- }
- }
-
- result := fmt.Sprintf("%s\n\nusage:\n caddy %s %s\n",
- helpText,
- subcommand.Name,
- strings.TrimSpace(subcommand.Usage),
- )
-
- if help := flagHelp(subcommand.Flags); help != "" {
- result += fmt.Sprintf("\nflags: (NOTE: prefix flags with `--` instead of `-`)\n%s", help)
- }
-
- result += "\n" + fullDocs + "\n"
-
- fmt.Print(result)
-
- return caddy.ExitCodeSuccess, nil
-}
-
// AdminAPIRequest makes an API request according to the CLI flags given,
// with the given HTTP method and request URI. If body is non-nil, it will
// be assumed to be Content-Type application/json. The caller should close