Skip to content

Commit 0e09ed3

Browse files
authored
Merge pull request #33 from norwoodj/issue-28-output
feat: adds a --output-file cli option for specifying the file to whic…
2 parents 1923cc6 + 37501cb commit 0e09ed3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmd/helm-docs/command_line.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ func newHelmDocsCommand(run func(cmd *cobra.Command, args []string)) (*cobra.Com
4646
command.PersistentFlags().BoolP("dry-run", "d", false, "don't actually render any markdown files just print to stdout passed")
4747
command.PersistentFlags().StringP("ignore-file", "i", ".helmdocsignore", "The filename to use as an ignore file to exclude chart directories")
4848
command.PersistentFlags().StringP("log-level", "l", "info", logLevelUsage)
49-
command.PersistentFlags().StringP("template-file", "t", "README.md.gotmpl", "gotemplate file to use to generate documentation for charts")
49+
command.PersistentFlags().StringP("output-file", "o", "README.md", "markdown file path relative to each chart directory to which rendered documentation will be written")
50+
command.PersistentFlags().StringP("template-file", "t", "README.md.gotmpl", "gotemplate file path relative to each chart directory from which documentation will be generated")
5051

5152
viper.AutomaticEnv()
5253
viper.SetEnvPrefix("HELM_DOCS")

pkg/document/generate.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ import (
77

88
"github.com/norwoodj/helm-docs/pkg/helm"
99
log "github.com/sirupsen/logrus"
10+
"github.com/spf13/viper"
1011
)
1112

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

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

1921
if err != nil {
2022
return nil, err

0 commit comments

Comments
 (0)