Skip to content

Commit

Permalink
Remove unneeded error from printOption method
Browse files Browse the repository at this point in the history
The code below doesn't really need the `error` as return type, so I remove it

```go
func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
	flags := cmd.NonInheritedFlags()
	flags.SetOutput(buf)
	if flags.HasAvailableFlags() {
		parentFlags.PrintDefaults()
		buf.WriteString("```\n\n")
	}
	return nil
}
```

Merge spf13/cobra#1549
  • Loading branch information
YikSanChan authored and hoshsadiq committed Feb 8, 2022
1 parent bd8b35c commit 73e1b0f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/md_docs.go
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/spf13/cobra"
)

func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) {
flags := cmd.NonInheritedFlags()
flags.SetOutput(buf)
if flags.HasAvailableFlags() {
Expand All @@ -42,7 +42,6 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
parentFlags.PrintDefaults()
buf.WriteString("```\n\n")
}
return nil
}

// GenMarkdown creates markdown output.
Expand Down Expand Up @@ -74,9 +73,8 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string)
buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.Example))
}

if err := printOptions(buf, cmd, name); err != nil {
return err
}
printOptions(buf, cmd, name)

if hasSeeAlso(cmd) {
buf.WriteString("### SEE ALSO\n\n")
if cmd.HasParent() {
Expand Down

0 comments on commit 73e1b0f

Please sign in to comment.