Compare commits
No commits in common. "f2da3dadd79e686850b1394050927d9dd9412763" and "743d0eed7cf24e2ca9eaacbdb29fbbb831b9ed0e" have entirely different histories.
f2da3dadd7
...
743d0eed7c
31
cmd/help.go
31
cmd/help.go
@ -23,7 +23,19 @@ func HelpCmd(args CmdArgs) (int, error) {
|
|||||||
if len(argv) == 0 {
|
if len(argv) == 0 {
|
||||||
printHelp(commandRegistry)
|
printHelp(commandRegistry)
|
||||||
} else if len(argv) >= 1 {
|
} else if len(argv) >= 1 {
|
||||||
printCmdHelp(argv[0])
|
subCmd, ok := commandRegistry[argv[0]]
|
||||||
|
if !ok {
|
||||||
|
fmt.Printf("unknown commnnd: %s\n", argv[0])
|
||||||
|
return ExitError, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if subCmd.Use != "" {
|
||||||
|
fmt.Printf("usage:\n lume %s %s\n", subCmd.Name, subCmd.Use)
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Print("flags:\n")
|
||||||
|
subCmd.Flags.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
return ExitSuccess, nil
|
return ExitSuccess, nil
|
||||||
@ -46,20 +58,3 @@ func printHelp(commands map[string]Command) {
|
|||||||
fmt.Printf(" %-*s %s\n", maxLen, c.Name, c.Short)
|
fmt.Printf(" %-*s %s\n", maxLen, c.Name, c.Short)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printCmdHelp(name string) error {
|
|
||||||
subCmd, ok := commandRegistry[name]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("unknown commnnd: %s\n", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if subCmd.Use != "" {
|
|
||||||
fmt.Printf("usage:\n lume %s %s\n", subCmd.Name, subCmd.Use)
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Print("flags:\n")
|
|
||||||
subCmd.Flags.PrintDefaults()
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user