Skip to content

Commit

Permalink
feat: better usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Jun 7, 2021
1 parent d8f67f9 commit d1a8f1e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,24 @@ func generateUsageTemplate(cmd *cobra.Command) string {
ret += "\n"
}

ret += pterm.Sprintfln("%s [global options] command [options] [arguments...]", rootCmd.Use)
ret += pterm.Sprintfln("%s", pterm.LightMagenta(getParentString(cmd)))

return ret
}

func getParentString(cmd *cobra.Command) (ret string) {
c := cmd.Parent()

ret = cmd.Use

for c != nil {
ret = c.Name() + " " + ret
c = c.Parent()
}

return
}

func generateDescriptionTemplate(description string) string {
var ret string

Expand Down

0 comments on commit d1a8f1e

Please sign in to comment.