Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command line help #6052

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ package utils
import (
"crypto/ecdsa"
"fmt"
"io"
"math/big"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"text/tabwriter"
"text/template"

"github.com/c2h5oh/datasize"
"github.com/ledgerwatch/erigon-lib/common/cmp"
Expand Down Expand Up @@ -59,32 +56,6 @@ import (
"github.com/ledgerwatch/erigon/params/networkname"
)

func init() {
cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
VERSION:
{{.Version}}
COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
cli.HelpPrinter = printHelp
}

func printHelp(out io.Writer, templ string, data interface{}) {
funcMap := template.FuncMap{"join": strings.Join}
t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
w := tabwriter.NewWriter(out, 38, 8, 2, ' ', 0)
if err := t.Execute(w, data); err != nil {
panic(err)
}
w.Flush()
}

// These are all the command line flags we support.
// If you add to this list, please remember to include the
// flag in the appropriate command definition.
Expand Down