Skip to content

Commit 845469c

Browse files
committed
Support outputing to file for absolute path
`--output-file` or corresponding `output.file` config can now support absolute path as well as relative path to root of module foler. For example all of the followings are valid: $ cd /path/to/module $ tree . . ├── docs │   └── README.md ├── ... └── main.tf # this works, relative path $ terraform-docs markdown table --output-file ../docs/README.md . # so does this, absolute path $ terraform-docs markdown table --output-file /path/to/module/docs/README.md . Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
1 parent a9f9782 commit 845469c

20 files changed

+77
-18
lines changed

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewCommand() *cobra.Command {
6161
cmd.PersistentFlags().StringSliceVar(&config.Sections.Show, "show", []string{}, "show section ["+cli.AllSections+"]")
6262
cmd.PersistentFlags().StringSliceVar(&config.Sections.Hide, "hide", []string{}, "hide section ["+cli.AllSections+"]")
6363

64-
cmd.PersistentFlags().StringVar(&config.Output.File, "output-file", "", "File in module directory to insert output into (default \"\")")
64+
cmd.PersistentFlags().StringVar(&config.Output.File, "output-file", "", "File path to insert output into (default \"\")")
6565
cmd.PersistentFlags().StringVar(&config.Output.Mode, "output-mode", "inject", "Output to file method ["+cli.OutputModes+"]")
6666
cmd.PersistentFlags().StringVar(&config.Output.Template, "output-template", cli.OutputTemplate, "Output template")
6767

docs/reference/asciidoc-document.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ terraform-docs asciidoc document [PATH] [flags]
3232
--header-from string relative path of a file to read header from (default "main.tf")
3333
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
3434
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
35-
--output-file string File in module directory to insert output into (default "")
35+
--output-file string File path to insert output into (default "")
3636
--output-mode string Output to file method [inject, replace] (default "inject")
3737
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3838
--output-values inject output values into outputs (default false)

docs/reference/asciidoc-table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ terraform-docs asciidoc table [PATH] [flags]
3232
--header-from string relative path of a file to read header from (default "main.tf")
3333
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
3434
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
35-
--output-file string File in module directory to insert output into (default "")
35+
--output-file string File path to insert output into (default "")
3636
--output-mode string Output to file method [inject, replace] (default "inject")
3737
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3838
--output-values inject output values into outputs (default false)

docs/reference/asciidoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ terraform-docs asciidoc [PATH] [flags]
3535
--footer-from string relative path of a file to read footer from (default "")
3636
--header-from string relative path of a file to read header from (default "main.tf")
3737
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
38-
--output-file string File in module directory to insert output into (default "")
38+
--output-file string File path to insert output into (default "")
3939
--output-mode string Output to file method [inject, replace] (default "inject")
4040
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4141
--output-values inject output values into outputs (default false)

docs/reference/json.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ terraform-docs json [PATH] [flags]
3030
--footer-from string relative path of a file to read footer from (default "")
3131
--header-from string relative path of a file to read header from (default "main.tf")
3232
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
33-
--output-file string File in module directory to insert output into (default "")
33+
--output-file string File path to insert output into (default "")
3434
--output-mode string Output to file method [inject, replace] (default "inject")
3535
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3636
--output-values inject output values into outputs (default false)

docs/reference/markdown-document.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ terraform-docs markdown document [PATH] [flags]
3333
--header-from string relative path of a file to read header from (default "main.tf")
3434
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
3535
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
36-
--output-file string File in module directory to insert output into (default "")
36+
--output-file string File path to insert output into (default "")
3737
--output-mode string Output to file method [inject, replace] (default "inject")
3838
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3939
--output-values inject output values into outputs (default false)

docs/reference/markdown-table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ terraform-docs markdown table [PATH] [flags]
3333
--header-from string relative path of a file to read header from (default "main.tf")
3434
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
3535
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
36-
--output-file string File in module directory to insert output into (default "")
36+
--output-file string File path to insert output into (default "")
3737
--output-mode string Output to file method [inject, replace] (default "inject")
3838
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3939
--output-values inject output values into outputs (default false)

docs/reference/markdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ terraform-docs markdown [PATH] [flags]
3636
--footer-from string relative path of a file to read footer from (default "")
3737
--header-from string relative path of a file to read header from (default "main.tf")
3838
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
39-
--output-file string File in module directory to insert output into (default "")
39+
--output-file string File path to insert output into (default "")
4040
--output-mode string Output to file method [inject, replace] (default "inject")
4141
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4242
--output-values inject output values into outputs (default false)

docs/reference/pretty.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ terraform-docs pretty [PATH] [flags]
3030
--footer-from string relative path of a file to read footer from (default "")
3131
--header-from string relative path of a file to read header from (default "main.tf")
3232
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
33-
--output-file string File in module directory to insert output into (default "")
33+
--output-file string File path to insert output into (default "")
3434
--output-mode string Output to file method [inject, replace] (default "inject")
3535
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3636
--output-values inject output values into outputs (default false)

docs/reference/terraform-docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform-docs [PATH] [flags]
2424
--header-from string relative path of a file to read header from (default "main.tf")
2525
-h, --help help for terraform-docs
2626
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
27-
--output-file string File in module directory to insert output into (default "")
27+
--output-file string File path to insert output into (default "")
2828
--output-mode string Output to file method [inject, replace] (default "inject")
2929
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3030
--output-values inject output values into outputs (default false)

0 commit comments

Comments
 (0)