Skip to content
Open
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
2 changes: 2 additions & 0 deletions docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ type (
TakesValue bool
Default string
EnvVars []string
Type string
}
)

Expand Down Expand Up @@ -406,6 +407,7 @@ func (tt tabularTemplate) PrepareFlags(flags []cli.Flag) []cliTabularFlagTemplat
EnvVars: flag.GetEnvVars(),
TakesValue: flag.TakesValue(),
Default: getFlagDefaultValue(flag),
Type: flag.TypeName(),
}

if boolFlag, isBool := appFlag.(*cli.BoolFlag); isBool {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/urfave/cli-docs/v3

go 1.18
go 1.24.4

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v3 v3.0.0-alpha9.2
github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v3 v3.4.1
)

require (
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v3 v3.0.0-alpha9.2 h1:CL8llQj3dGRLVQQzHxS+ZYRLanOuhyK1fXgLKD+qV+Y=
github.com/urfave/cli/v3 v3.0.0-alpha9.2/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM=
github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
5 changes: 3 additions & 2 deletions markdown_tabular.md.gotmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{ define "flags" }}
| Name | Description | Default value | Environment variables |
|------|-------------|:-------------:|:---------------------:|
| Name | Description | Type | Default value | Environment variables |
|------|-------------|------|:-------------:|:---------------------:|
{{ 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 $flag.EnvVars }}`{{ join $flag.EnvVars "`, `" }}`{{ else }}*none*{{ end }}
{{- /**/ -}} |
Expand Down
40 changes: 20 additions & 20 deletions testdata/expected-tabular-markdown-custom-app-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ $ /usr/local/bin [GLOBAL FLAGS] [COMMAND] [COMMAND FLAGS] [ARGUMENTS...]

Global flags:

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

### `config` command (aliases: `c`)

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

The following flags are supported:

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

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

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

### `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 | Default value | Environment variables |
|-----------------------------|-----------------|:-------------:|:---------------------:|
| `--sub-command-flag` (`-s`) | some usage text | `false` | *none* |
| Name | Description | Type | Default value | Environment variables |
|-----------------------------|-----------------|------|:-------------:|:---------------------:|
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
40 changes: 20 additions & 20 deletions testdata/expected-tabular-markdown-full.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ $ app [GLOBAL FLAGS] [COMMAND] [COMMAND FLAGS] [ARGUMENTS...]

Global flags:

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

### `config` command (aliases: `c`)

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

The following flags are supported:

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

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

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

### `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 | Default value | Environment variables |
|-----------------------------|-----------------|:-------------:|:---------------------:|
| `--sub-command-flag` (`-s`) | some usage text | `false` | *none* |
| Name | Description | Type | Default value | Environment variables |
|-----------------------------|-----------------|------|:-------------:|:---------------------:|
| `--sub-command-flag` (`-s`) | some usage text | bool | `false` | *none* |
Loading