Skip to content

Commit

Permalink
Support mlr help flag --foo
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed May 15, 2023
1 parent b822ff0 commit 556757d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions internal/pkg/terminals/help/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func init() {
{
name: "Flags",
handlerInfos: []tHandlerInfo{
{name: "flags", zaryHandlerFunc: showFlagHelp},
{name: "flags", zaryHandlerFunc: showFlagsHelp},
{name: "flag", varArgHandlerFunc: helpForFlag},
{name: "list-separator-aliases", zaryHandlerFunc: listSeparatorAliases},
{name: "list-separator-regex-aliases", zaryHandlerFunc: listSeparatorRegexAliases},
// Per-section entries will be computed and installed below
Expand Down Expand Up @@ -311,10 +312,22 @@ func listTopics() {
}

// ----------------------------------------------------------------
func showFlagHelp() {
func showFlagsHelp() {
cli.FLAG_TABLE.ShowHelp()
}

func helpForFlag(args []string) {
for i, arg := range args {
if i > 0 {
fmt.Println()
}
fmt.Printf("%s:\n", arg)
if !cli.FLAG_TABLE.ShowHelpForFlag(arg) {
fmt.Println("Not found.")
}
}
}

func listSeparatorAliases() {
cli.ListSeparatorAliasesForOnlineHelp()
}
Expand Down Expand Up @@ -504,7 +517,7 @@ func helpTypeArithmeticInfo() {

// ----------------------------------------------------------------
// listFlagSections et al. are for webdoc/manpage autogen in the miller/docs
// and miller/man subdirectories. Unlike showFlagHelp where all looping over
// and miller/man subdirectories. Unlike showFlagsHelp where all looping over
// the flags table, its sections, and flags within each section is done within
// this Go program, by contrast the following few methods expose the hierarchy
// to standard output, letting the calling programs (nominally Ruby autogen
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/terminals/regtest/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func regTestUsage(verbName string, o *os.File, exitCode int) {
// Here the args are the full Miller command line: "mlr regtest --foo bar".
func RegTestMain(args []string) int {

exeName := "mlr"
exeName := os.Args[0]
verbName := args[0]
argc := len(args)
argi := 1
Expand Down

0 comments on commit 556757d

Please sign in to comment.