Skip to content

Commit a70fcdc

Browse files
committed
Merge branch 'main' into DefaultText
2 parents 434bec6 + 6d6ab09 commit a70fcdc

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

markdown_tabular.md.gotmpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
{{ define "flags" }}
2-
| Name | Description | Type | Default value | Environment variables |
3-
|------|-------------|------|:-------------:|:---------------------:|
2+
{{- $hasEnvVars := false -}}
3+
{{- range . -}}
4+
{{- if and (not $hasEnvVars) .EnvVars -}}
5+
{{- $hasEnvVars = true -}}
6+
{{- end -}}
7+
{{- end }}
8+
| Name | Description | Type | Default value {{ if $hasEnvVars }}| Environment variables {{ end }}|
9+
|------|-------------|------|:-------------:{{ if $hasEnvVars }}|:---------------------:{{ end }}|
410
{{ range $flag := . -}}
511
{{- /**/ -}} | `{{ $flag.Name }}{{ if $flag.TakesValue }}="…"{{ end }}` {{ if $flag.Aliases }}(`{{ join $flag.Aliases "`, `" }}`) {{ end }}
612
{{- /**/ -}} | {{ $flag.Usage }}
713
{{- /**/ -}} | {{ $flag.Type }}
814
{{- /**/ -}} | {{ if $flag.Default }}{{ $flag.Default }}{{ end }}
15+
{{- if $hasEnvVars -}}
916
{{- /**/ -}} | {{ if $flag.EnvVars }}`{{ join $flag.EnvVars "`, `" }}`{{ else }}*none*{{ end }}
17+
{{- end -}}
1018
{{- /**/ -}} |
1119
{{ end }}
1220
{{ end }}

testdata/expected-tabular-markdown-custom-app-path.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ $ /usr/local/bin [GLOBAL FLAGS] config [COMMAND FLAGS] [ARGUMENTS...]
3333

3434
The following flags are supported:
3535

36-
| Name | Description | Type | Default value | Environment variables |
37-
|-----------------------------|--------------------|--------|:-------------:|:---------------------:|
38-
| `--flag="…"` (`--fl`, `-f`) | | string | | *none* |
39-
| `--another-flag` (`-b`) | another usage text | bool | `false` | *none* |
36+
| Name | Description | Type | Default value |
37+
|-----------------------------|--------------------|--------|:-------------:|
38+
| `--flag="…"` (`--fl`, `-f`) | | string |
39+
| `--another-flag` (`-b`) | another usage text | bool | `false` |
4040

4141
### `config sub-config` subcommand (aliases: `s`, `ss`)
4242

@@ -50,10 +50,10 @@ $ /usr/local/bin [GLOBAL FLAGS] config sub-config [COMMAND FLAGS] [ARGUMENTS...]
5050

5151
The following flags are supported:
5252

53-
| Name | Description | Type | Default value | Environment variables |
54-
|-------------------------------------|-----------------|--------|:-------------:|:---------------------:|
55-
| `--sub-flag="…"` (`--sub-fl`, `-s`) | | string | | *none* |
56-
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
53+
| Name | Description | Type | Default value |
54+
|-------------------------------------|-----------------|--------|:-------------:|
55+
| `--sub-flag="…"` (`--sub-fl`, `-s`) | | string |
56+
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` |
5757

5858
### `info` command (aliases: `i`, `in`)
5959

@@ -94,10 +94,10 @@ $ /usr/local/bin [GLOBAL FLAGS] usage [COMMAND FLAGS] [ARGUMENTS...]
9494
9595
The following flags are supported:
9696

97-
| Name | Description | Type | Default value | Environment variables |
98-
|-----------------------------|--------------------|--------|:-------------:|:---------------------:|
99-
| `--flag="…"` (`--fl`, `-f`) | | string | | *none* |
100-
| `--another-flag` (`-b`) | another usage text | bool | `false` | *none* |
97+
| Name | Description | Type | Default value |
98+
|-----------------------------|--------------------|--------|:-------------:|
99+
| `--flag="…"` (`--fl`, `-f`) | | string |
100+
| `--another-flag` (`-b`) | another usage text | bool | `false` |
101101

102102
### `usage sub-usage` subcommand (aliases: `su`)
103103

@@ -113,6 +113,6 @@ $ /usr/local/bin [GLOBAL FLAGS] usage sub-usage [COMMAND FLAGS] [ARGUMENTS...]
113113

114114
The following flags are supported:
115115

116-
| Name | Description | Type | Default value | Environment variables |
117-
|-----------------------------|-----------------|------|:-------------:|:---------------------:|
118-
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
116+
| Name | Description | Type | Default value |
117+
|-----------------------------|-----------------|------|:-------------:|
118+
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` |

testdata/expected-tabular-markdown-full.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ $ app [GLOBAL FLAGS] config [COMMAND FLAGS] [ARGUMENTS...]
3333

3434
The following flags are supported:
3535

36-
| Name | Description | Type | Default value | Environment variables |
37-
|-----------------------------|--------------------|--------|:-------------:|:---------------------:|
38-
| `--flag="…"` (`--fl`, `-f`) | | string | | *none* |
39-
| `--another-flag` (`-b`) | another usage text | bool | `false` | *none* |
36+
| Name | Description | Type | Default value |
37+
|-----------------------------|--------------------|--------|:-------------:|
38+
| `--flag="…"` (`--fl`, `-f`) | | string |
39+
| `--another-flag` (`-b`) | another usage text | bool | `false` |
4040

4141
### `config sub-config` subcommand (aliases: `s`, `ss`)
4242

@@ -50,10 +50,10 @@ $ app [GLOBAL FLAGS] config sub-config [COMMAND FLAGS] [ARGUMENTS...]
5050

5151
The following flags are supported:
5252

53-
| Name | Description | Type | Default value | Environment variables |
54-
|-------------------------------------|-----------------|--------|:-------------:|:---------------------:|
55-
| `--sub-flag="…"` (`--sub-fl`, `-s`) | | string | | *none* |
56-
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
53+
| Name | Description | Type | Default value |
54+
|-------------------------------------|-----------------|--------|:-------------:|
55+
| `--sub-flag="…"` (`--sub-fl`, `-s`) | | string |
56+
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` |
5757

5858
### `info` command (aliases: `i`, `in`)
5959

@@ -94,10 +94,10 @@ $ app [GLOBAL FLAGS] usage [COMMAND FLAGS] [ARGUMENTS...]
9494
9595
The following flags are supported:
9696

97-
| Name | Description | Type | Default value | Environment variables |
98-
|-----------------------------|--------------------|--------|:-------------:|:---------------------:|
99-
| `--flag="…"` (`--fl`, `-f`) | | string | | *none* |
100-
| `--another-flag` (`-b`) | another usage text | bool | `false` | *none* |
97+
| Name | Description | Type | Default value |
98+
|-----------------------------|--------------------|--------|:-------------:|
99+
| `--flag="…"` (`--fl`, `-f`) | | string |
100+
| `--another-flag` (`-b`) | another usage text | bool | `false` |
101101

102102
### `usage sub-usage` subcommand (aliases: `su`)
103103

@@ -113,6 +113,6 @@ $ app [GLOBAL FLAGS] usage sub-usage [COMMAND FLAGS] [ARGUMENTS...]
113113

114114
The following flags are supported:
115115

116-
| Name | Description | Type | Default value | Environment variables |
117-
|-----------------------------|-----------------|------|:-------------:|:---------------------:|
118-
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
116+
| Name | Description | Type | Default value |
117+
|-----------------------------|-----------------|------|:-------------:|
118+
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` |

0 commit comments

Comments
 (0)