Skip to content

Commit

Permalink
Merge pull request #33 from norwoodj/issue-28-output
Browse files Browse the repository at this point in the history
feat: adds a --output-file cli option for specifying the file to whic…
  • Loading branch information
norwoodj authored Mar 30, 2020
2 parents 1923cc6 + 37501cb commit 0e09ed3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/helm-docs/command_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func newHelmDocsCommand(run func(cmd *cobra.Command, args []string)) (*cobra.Com
command.PersistentFlags().BoolP("dry-run", "d", false, "don't actually render any markdown files just print to stdout passed")
command.PersistentFlags().StringP("ignore-file", "i", ".helmdocsignore", "The filename to use as an ignore file to exclude chart directories")
command.PersistentFlags().StringP("log-level", "l", "info", logLevelUsage)
command.PersistentFlags().StringP("template-file", "t", "README.md.gotmpl", "gotemplate file to use to generate documentation for charts")
command.PersistentFlags().StringP("output-file", "o", "README.md", "markdown file path relative to each chart directory to which rendered documentation will be written")
command.PersistentFlags().StringP("template-file", "t", "README.md.gotmpl", "gotemplate file path relative to each chart directory from which documentation will be generated")

viper.AutomaticEnv()
viper.SetEnvPrefix("HELM_DOCS")
Expand Down
4 changes: 3 additions & 1 deletion pkg/document/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import (

"github.com/norwoodj/helm-docs/pkg/helm"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)

func getOutputFile(chartDirectory string, dryRun bool) (*os.File, error) {
if dryRun {
return os.Stdout, nil
}

f, err := os.Create(fmt.Sprintf("%s/README.md", chartDirectory))
outputFile := viper.GetString("output-file")
f, err := os.Create(fmt.Sprintf("%s/%s", chartDirectory, outputFile))

if err != nil {
return nil, err
Expand Down

0 comments on commit 0e09ed3

Please sign in to comment.