Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions markdown_tabular.md.gotmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{{ define "flags" }}
| Name | Description | Type | Default value | Environment variables |
|------|-------------|------|:-------------:|:---------------------:|
{{- $hasEnvVars := false -}}
{{- range . -}}
{{- if and (not $hasEnvVars) .EnvVars -}}
{{- $hasEnvVars = true -}}
{{- end -}}
{{- end }}
| Name | Description | Type | Default value {{ if $hasEnvVars }}| Environment variables {{ end }}|
|------|-------------|------|:-------------:{{ if $hasEnvVars }}|:---------------------:{{ end }}|
{{ range $flag := . -}}
{{- /**/ -}} | `{{ $flag.Name }}{{ if $flag.TakesValue }}="…"{{ end }}` {{ if $flag.Aliases }}(`{{ join $flag.Aliases "`, `" }}`) {{ end }}
{{- /**/ -}} | {{ $flag.Usage }}
{{- /**/ -}} | {{ $flag.Type }}
{{- /**/ -}} | {{ if $flag.Default }}`{{ $flag.Default }}`{{ end }}
{{- if $hasEnvVars -}}
{{- /**/ -}} | {{ if $flag.EnvVars }}`{{ join $flag.EnvVars "`, `" }}`{{ else }}*none*{{ end }}
{{- end -}}
{{- /**/ -}} |
{{ end }}
{{ end }}
Expand Down
30 changes: 15 additions & 15 deletions testdata/expected-tabular-markdown-custom-app-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ $ /usr/local/bin [GLOBAL FLAGS] config [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand All @@ -49,10 +49,10 @@ $ /usr/local/bin [GLOBAL FLAGS] config sub-config [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand Down Expand Up @@ -93,10 +93,10 @@ $ /usr/local/bin [GLOBAL FLAGS] usage [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand All @@ -112,6 +112,6 @@ $ /usr/local/bin [GLOBAL FLAGS] usage sub-usage [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

| Name | Description | Type | Default value | Environment variables |
|-----------------------------|-----------------|------|:-------------:|:---------------------:|
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
| Name | Description | Type | Default value |
|-----------------------------|-----------------|------|:-------------:|
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` |
30 changes: 15 additions & 15 deletions testdata/expected-tabular-markdown-full.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ $ app [GLOBAL FLAGS] config [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand All @@ -49,10 +49,10 @@ $ app [GLOBAL FLAGS] config sub-config [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand Down Expand Up @@ -93,10 +93,10 @@ $ app [GLOBAL FLAGS] usage [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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

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

Expand All @@ -112,6 +112,6 @@ $ app [GLOBAL FLAGS] usage sub-usage [COMMAND FLAGS] [ARGUMENTS...]

The following flags are supported:

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