Skip to content

Commit

Permalink
Deprecate --show-all and --hide-all flags
Browse files Browse the repository at this point in the history
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 <khos2ow@gmail.com>
  • Loading branch information
khos2ow committed Apr 20, 2021
1 parent 684e827 commit 8c531b6
Show file tree
Hide file tree
Showing 22 changed files with 201 additions and 161 deletions.
11 changes: 7 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func NewCommand() *cobra.Command {

cmd.PersistentFlags().StringSliceVar(&config.Sections.Show, "show", []string{}, "show section ["+cli.AllSections+"]")
cmd.PersistentFlags().StringSliceVar(&config.Sections.Hide, "hide", []string{}, "hide section ["+cli.AllSections+"]")
cmd.PersistentFlags().BoolVar(&config.Sections.ShowAll, "show-all", true, "show all sections")
cmd.PersistentFlags().BoolVar(&config.Sections.HideAll, "hide-all", false, "hide all sections (default false)")

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

// deprecated flags ==>
cmd.PersistentFlags().BoolVar(new(bool), "show-all", true, "show all sections")
cmd.PersistentFlags().BoolVar(new(bool), "hide-all", false, "hide all sections (default false)")
cmd.PersistentFlags().MarkDeprecated("show-all", "more information: https://terraform-docs.io/user-guide/how-to/#visibility-of-sections\n\n") //nolint:errcheck,gosec
cmd.PersistentFlags().MarkDeprecated("hide-all", "more information: https://terraform-docs.io/user-guide/how-to/#visibility-of-sections\n\n") //nolint:errcheck,gosec

cmd.PersistentFlags().BoolVar(&config.Sort.Criteria.Required, "sort-by-required", false, "sort items by name and print required ones first (default false)")
cmd.PersistentFlags().BoolVar(&config.Sort.Criteria.Type, "sort-by-type", false, "sort items by type of them (default false)")
cmd.PersistentFlags().MarkDeprecated("sort-by-required", "use '--sort-by required' instead") //nolint:errcheck,gosec
cmd.PersistentFlags().MarkDeprecated("sort-by-type", "use '--sort-by type' instead") //nolint:errcheck,gosec
cmd.PersistentFlags().MarkDeprecated("sort-by-required", "use '--sort-by required' instead\n\n") //nolint:errcheck,gosec
cmd.PersistentFlags().MarkDeprecated("sort-by-type", "use '--sort-by type' instead\n\n") //nolint:errcheck,gosec
// <==

cmd.PersistentFlags().StringVar(&config.HeaderFrom, "header-from", "main.tf", "relative path of a file to read header from")
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/asciidoc-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ terraform-docs asciidoc document [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
Expand All @@ -41,7 +40,6 @@ terraform-docs asciidoc document [PATH] [flags]
--required show Required column or section (default true)
--sensitive show Sensitive column or section (default true)
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
--type show Type column or section (default true)
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/asciidoc-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ terraform-docs asciidoc table [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--indent int indention level of AsciiDoc sections [1, 2, 3, 4, 5] (default 2)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
Expand All @@ -41,7 +40,6 @@ terraform-docs asciidoc table [PATH] [flags]
--required show Required column or section (default true)
--sensitive show Sensitive column or section (default true)
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
--type show Type column or section (default true)
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/asciidoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ terraform-docs asciidoc [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ terraform-docs json [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/markdown-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ terraform-docs markdown document [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
Expand All @@ -42,7 +41,6 @@ terraform-docs markdown document [PATH] [flags]
--required show Required column or section (default true)
--sensitive show Sensitive column or section (default true)
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
--type show Type column or section (default true)
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/markdown-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ terraform-docs markdown table [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--indent int indention level of Markdown sections [1, 2, 3, 4, 5] (default 2)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
Expand All @@ -42,7 +41,6 @@ terraform-docs markdown table [PATH] [flags]
--required show Required column or section (default true)
--sensitive show Sensitive column or section (default true)
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
--type show Type column or section (default true)
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ terraform-docs markdown [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/pretty.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ terraform-docs pretty [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/terraform-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ terraform-docs [PATH] [flags]
--header-from string relative path of a file to read header from (default "main.tf")
-h, --help help for terraform-docs
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/tfvars-hcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ terraform-docs tfvars hcl [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/tfvars-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ terraform-docs tfvars json [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/tfvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ Generate terraform.tfvars of inputs.
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ terraform-docs toml [PATH] [flags]
--footer-from string relative path of a file to read footer from (default "")
--header-from string relative path of a file to read header from (default "main.tf")
--hide strings hide section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--hide-all hide all sections (default false)
--output-file string File in module directory to insert output into (default "")
--output-mode string Output to file method [inject, replace] (default "inject")
--output-template string Output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
--output-values inject output values into outputs (default false)
--output-values-from string inject output values from file into outputs (default "")
--show strings show section [data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
--show-all show all sections (default true)
--sort sort items (default true)
--sort-by string sort items by criteria [name, required, type] (default "name")
```
Expand Down
Loading

0 comments on commit 8c531b6

Please sign in to comment.