cmd/loop: remove custom cli-docs template override

Now that https://github.com/urfave/cli-docs/pull/15 removes empty environment
variable columns, we can rely on upstream and delete our embedded template copy.
This commit is contained in:
Boris Nagaev 2025-11-04 16:45:10 -03:00
parent b9832c475a
commit c32309ec5c
No known key found for this signature in database
4 changed files with 3 additions and 96 deletions

View file

@ -2,25 +2,12 @@ package main
import (
"context"
_ "embed"
"fmt"
docs "github.com/urfave/cli-docs/v3"
"github.com/urfave/cli/v3"
)
//go:embed markdown_tabular.md.gotmpl
var markdownTabularDocTemplate string
// We have a copy of this template taken from
// https://github.com/urfave/cli-docs where we remove column
// "Environment variables" if it has no values.
// TODO: remove this when https://github.com/urfave/cli-docs/pull/15
// is merged.
func init() {
docs.MarkdownTabularDocTemplate = markdownTabularDocTemplate
}
var printManCommand = &cli.Command{
Name: "man",
Usage: "prints man file",

View file

@ -1,80 +0,0 @@
{{ define "flags" }}
{{- $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 }}
{{ define "command" }}
### `{{ .Name }}` {{ if gt .Level 0 }}sub{{ end }}command{{ if .Aliases }} (aliases: `{{ join .Aliases "`, `" }}`){{ end }}
{{ if .Usage }}
{{ .Usage }}.
{{ end }}
{{ if .UsageText }}
{{ range $line := .UsageText -}}
> {{ $line }}
{{ end -}}
{{ end }}
{{ if .Description }}
{{ .Description }}.
{{ end }}
Usage:
```bash
$ {{ .AppPath }} [GLOBAL FLAGS] {{ .Name }}{{ if .Flags }} [COMMAND FLAGS]{{ end }} {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }}
```
{{ if .Flags -}}
The following flags are supported:
{{ template "flags" .Flags }}
{{ end -}}
{{ if .SubCommands -}}
{{ range $subCmd := .SubCommands -}}
{{ template "command" $subCmd }}
{{ end -}}
{{ end -}}
{{ end }}
## CLI interface{{ if .Name }} - {{ .Name }}{{ end }}
{{ if .Description }}{{ .Description }}.
{{ end }}
{{ if .Usage }}{{ .Usage }}.
{{ end }}
{{ if .UsageText }}
{{ range $line := .UsageText -}}
> {{ $line }}
{{ end -}}
{{ end }}
Usage:
```bash
$ {{ .AppPath }}{{ if .GlobalFlags }} [GLOBAL FLAGS]{{ end }} [COMMAND] [COMMAND FLAGS] {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }}
```
{{ if .GlobalFlags }}
Global flags:
{{ template "flags" .GlobalFlags }}
{{ end -}}
{{ if .Commands -}}
{{ range $cmd := .Commands -}}
{{ template "command" $cmd }}
{{ end }}
{{- end }}