Skip to content

Commit

Permalink
Added additional logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Witkowski committed Sep 15, 2023
1 parent 259efbf commit 07877ab
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion cmd/provenanced/cmd/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"

"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"
Expand All @@ -26,12 +27,46 @@ func GetDocGenCmd() *cobra.Command {
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
dir := args[0]
if !exists(dir) {
err := os.Mkdir(dir, 0755)
if err != nil {
return err
}

Check warning on line 35 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L30-L35

Added lines #L30 - L35 were not covered by tests
}

// Check if at least one flag is enabled

markdown, err := cmd.Flags().GetBool(FlagMarkdown)
if err != nil {
return err
}
if markdown {
doc.GenMarkdownTree(cmd.Root(), args[0])
doc.GenMarkdownTree(cmd.Root(), dir)

Check failure on line 45 in cmd/provenanced/cmd/docgen.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `doc.GenMarkdownTree` is not checked (errcheck)
}

Check warning on line 46 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L40-L46

Added lines #L40 - L46 were not covered by tests

yaml, err := cmd.Flags().GetBool(FlagYaml)
if err != nil {
return err
}
if yaml {
doc.GenYamlTree(cmd.Root(), dir)

Check failure on line 53 in cmd/provenanced/cmd/docgen.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `doc.GenYamlTree` is not checked (errcheck)
}

Check warning on line 54 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L48-L54

Added lines #L48 - L54 were not covered by tests

rest, err := cmd.Flags().GetBool(FlagRest)
if err != nil {
return err
}
if rest {
doc.GenReSTTree(cmd.Root(), dir)

Check failure on line 61 in cmd/provenanced/cmd/docgen.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `doc.GenReSTTree` is not checked (errcheck)
}

Check warning on line 62 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L56-L62

Added lines #L56 - L62 were not covered by tests

manpage, err := cmd.Flags().GetBool(FlagManpage)
if err != nil {
return err
}
if manpage {
doc.GenManTree(cmd.Root(), nil, dir)

Check failure on line 69 in cmd/provenanced/cmd/docgen.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `doc.GenManTree` is not checked (errcheck)
}

Check warning on line 70 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L64-L70

Added lines #L64 - L70 were not covered by tests

return nil

Check warning on line 72 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L72

Added line #L72 was not covered by tests
Expand All @@ -45,3 +80,8 @@ func GetDocGenCmd() *cobra.Command {

return cmd
}

func exists(dir string) bool {
_, err := os.Stat(dir)
return err == nil

Check warning on line 86 in cmd/provenanced/cmd/docgen.go

View check run for this annotation

Codecov / codecov/patch

cmd/provenanced/cmd/docgen.go#L84-L86

Added lines #L84 - L86 were not covered by tests
}

0 comments on commit 07877ab

Please sign in to comment.