Skip to content

Commit 8c531b6

Browse files
committed
Deprecate --show-all and --hide-all flags
As of `v0.13.0` flags `--show-all` and `--hide-all` are deprecated in favor of explicit use of `--show` and `--hide`. In other words when `--show <section>` is used, only `<section>` will be shown. If you want to show multiple sections and hide the rest you can specify multiple `--show` flags. The same logic is also applied to `--hide`. # show 'inputs' and hide everything else $ terraform-docs --show inputs <formatter> # show 'inputs' and show 'outputs' and hide everything else $ terraform-docs --show inputs --show outputs <formatter> # hide 'header' and show everything else $ terraform-docs --hide header <formatter> # hide 'header' and hide 'providers' and show everything else $ terraform-docs --hide header --hide providers <formatter> Note: Using `--show` or `--hide` CLI flag will completely override the values from `.terraform-docs.yml`. Example: $ cat .terraform-docs.yml sections: show: - inputs - outputs # example 1: this will only show 'providers' $ terraform-docs --show providers . # example 2: this will hide 'inputs' and hide 'providers' and show everything else $ terraform-docs --hide inputs --hide providers . Signed-off-by: Khosrow Moossavi <[email protected]>
1 parent 684e827 commit 8c531b6

22 files changed

+201
-161
lines changed

cmd/root.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ func NewCommand() *cobra.Command {
6060

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+"]")
63-
cmd.PersistentFlags().BoolVar(&config.Sections.ShowAll, "show-all", true, "show all sections")
64-
cmd.PersistentFlags().BoolVar(&config.Sections.HideAll, "hide-all", false, "hide all sections (default false)")
6563

6664
cmd.PersistentFlags().StringVar(&config.Output.File, "output-file", "", "File in module directory to insert output into (default \"\")")
6765
cmd.PersistentFlags().StringVar(&config.Output.Mode, "output-mode", "inject", "Output to file method ["+cli.OutputModes+"]")
@@ -71,10 +69,15 @@ func NewCommand() *cobra.Command {
7169
cmd.PersistentFlags().StringVar(&config.Sort.By, "sort-by", "name", "sort items by criteria ["+cli.SortTypes+"]")
7270

7371
// deprecated flags ==>
72+
cmd.PersistentFlags().BoolVar(new(bool), "show-all", true, "show all sections")
73+
cmd.PersistentFlags().BoolVar(new(bool), "hide-all", false, "hide all sections (default false)")
74+
cmd.PersistentFlags().MarkDeprecated("show-all", "more information: https://terraform-docs.io/user-guide/how-to/#visibility-of-sections\n\n") //nolint:errcheck,gosec
75+
cmd.PersistentFlags().MarkDeprecated("hide-all", "more information: https://terraform-docs.io/user-guide/how-to/#visibility-of-sections\n\n") //nolint:errcheck,gosec
76+
7477
cmd.PersistentFlags().BoolVar(&config.Sort.Criteria.Required, "sort-by-required", false, "sort items by name and print required ones first (default false)")
7578
cmd.PersistentFlags().BoolVar(&config.Sort.Criteria.Type, "sort-by-type", false, "sort items by type of them (default false)")
76-
cmd.PersistentFlags().MarkDeprecated("sort-by-required", "use '--sort-by required' instead") //nolint:errcheck,gosec
77-
cmd.PersistentFlags().MarkDeprecated("sort-by-type", "use '--sort-by type' instead") //nolint:errcheck,gosec
79+
cmd.PersistentFlags().MarkDeprecated("sort-by-required", "use '--sort-by required' instead\n\n") //nolint:errcheck,gosec
80+
cmd.PersistentFlags().MarkDeprecated("sort-by-type", "use '--sort-by type' instead\n\n") //nolint:errcheck,gosec
7881
// <==
7982

8083
cmd.PersistentFlags().StringVar(&config.HeaderFrom, "header-from", "main.tf", "relative path of a file to read header from")

docs/reference/asciidoc-document.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ terraform-docs asciidoc document [PATH] [flags]
3131
--footer-from string relative path of a file to read footer from (default "")
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]
34-
--hide-all hide all sections (default false)
3534
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
3635
--output-file string File in module directory to insert output into (default "")
3736
--output-mode string Output to file method [inject, replace] (default "inject")
@@ -41,7 +40,6 @@ terraform-docs asciidoc document [PATH] [flags]
4140
--required show Required column or section (default true)
4241
--sensitive show Sensitive column or section (default true)
4342
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
44-
--show-all show all sections (default true)
4543
--sort sort items (default true)
4644
--sort-by string sort items by criteria [name, required, type] (default "name")
4745
--type show Type column or section (default true)

docs/reference/asciidoc-table.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ terraform-docs asciidoc table [PATH] [flags]
3131
--footer-from string relative path of a file to read footer from (default "")
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]
34-
--hide-all hide all sections (default false)
3534
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
3635
--output-file string File in module directory to insert output into (default "")
3736
--output-mode string Output to file method [inject, replace] (default "inject")
@@ -41,7 +40,6 @@ terraform-docs asciidoc table [PATH] [flags]
4140
--required show Required column or section (default true)
4241
--sensitive show Sensitive column or section (default true)
4342
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
44-
--show-all show all sections (default true)
4543
--sort sort items (default true)
4644
--sort-by string sort items by criteria [name, required, type] (default "name")
4745
--type show Type column or section (default true)

docs/reference/asciidoc.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ 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-
--hide-all hide all sections (default false)
3938
--output-file string File in module directory to insert output into (default "")
4039
--output-mode string Output to file method [inject, replace] (default "inject")
4140
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4241
--output-values inject output values into outputs (default false)
4342
--output-values-from string inject output values from file into outputs (default "")
4443
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
45-
--show-all show all sections (default true)
4644
--sort sort items (default true)
4745
--sort-by string sort items by criteria [name, required, type] (default "name")
4846
```

docs/reference/json.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ 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-
--hide-all hide all sections (default false)
3433
--output-file string File in module directory to insert output into (default "")
3534
--output-mode string Output to file method [inject, replace] (default "inject")
3635
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3736
--output-values inject output values into outputs (default false)
3837
--output-values-from string inject output values from file into outputs (default "")
3938
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
40-
--show-all show all sections (default true)
4139
--sort sort items (default true)
4240
--sort-by string sort items by criteria [name, required, type] (default "name")
4341
```

docs/reference/markdown-document.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ terraform-docs markdown document [PATH] [flags]
3232
--footer-from string relative path of a file to read footer from (default "")
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]
35-
--hide-all hide all sections (default false)
3635
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
3736
--output-file string File in module directory to insert output into (default "")
3837
--output-mode string Output to file method [inject, replace] (default "inject")
@@ -42,7 +41,6 @@ terraform-docs markdown document [PATH] [flags]
4241
--required show Required column or section (default true)
4342
--sensitive show Sensitive column or section (default true)
4443
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
45-
--show-all show all sections (default true)
4644
--sort sort items (default true)
4745
--sort-by string sort items by criteria [name, required, type] (default "name")
4846
--type show Type column or section (default true)

docs/reference/markdown-table.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ terraform-docs markdown table [PATH] [flags]
3232
--footer-from string relative path of a file to read footer from (default "")
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]
35-
--hide-all hide all sections (default false)
3635
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
3736
--output-file string File in module directory to insert output into (default "")
3837
--output-mode string Output to file method [inject, replace] (default "inject")
@@ -42,7 +41,6 @@ terraform-docs markdown table [PATH] [flags]
4241
--required show Required column or section (default true)
4342
--sensitive show Sensitive column or section (default true)
4443
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
45-
--show-all show all sections (default true)
4644
--sort sort items (default true)
4745
--sort-by string sort items by criteria [name, required, type] (default "name")
4846
--type show Type column or section (default true)

docs/reference/markdown.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ 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-
--hide-all hide all sections (default false)
4039
--output-file string File in module directory to insert output into (default "")
4140
--output-mode string Output to file method [inject, replace] (default "inject")
4241
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4342
--output-values inject output values into outputs (default false)
4443
--output-values-from string inject output values from file into outputs (default "")
4544
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
46-
--show-all show all sections (default true)
4745
--sort sort items (default true)
4846
--sort-by string sort items by criteria [name, required, type] (default "name")
4947
```

docs/reference/pretty.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ 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-
--hide-all hide all sections (default false)
3433
--output-file string File in module directory to insert output into (default "")
3534
--output-mode string Output to file method [inject, replace] (default "inject")
3635
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3736
--output-values inject output values into outputs (default false)
3837
--output-values-from string inject output values from file into outputs (default "")
3938
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
40-
--show-all show all sections (default true)
4139
--sort sort items (default true)
4240
--sort-by string sort items by criteria [name, required, type] (default "name")
4341
```

docs/reference/terraform-docs.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ 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-
--hide-all hide all sections (default false)
2827
--output-file string File in module directory to insert output into (default "")
2928
--output-mode string Output to file method [inject, replace] (default "inject")
3029
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3130
--output-values inject output values into outputs (default false)
3231
--output-values-from string inject output values from file into outputs (default "")
3332
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
34-
--show-all show all sections (default true)
3533
--sort sort items (default true)
3634
--sort-by string sort items by criteria [name, required, type] (default "name")
3735
```

0 commit comments

Comments
 (0)