pax_global_header00006660000000000000000000000064150650131330014507gustar00rootroot0000000000000052 comment=21e00b628be344ae980341f1ebb919f4a1d17f78 cli-docs-3.1.0/000077500000000000000000000000001506501313300132055ustar00rootroot00000000000000cli-docs-3.1.0/.gitattributes000066400000000000000000000000251506501313300160750ustar00rootroot00000000000000*.gotmpl text eol=lf cli-docs-3.1.0/.github/000077500000000000000000000000001506501313300145455ustar00rootroot00000000000000cli-docs-3.1.0/.github/CODEOWNERS000066400000000000000000000001641506501313300161410ustar00rootroot00000000000000# See https://help.github.com/articles/about-codeowners/ # for more info about CODEOWNERS file * @urfave/cli cli-docs-3.1.0/.github/workflows/000077500000000000000000000000001506501313300166025ustar00rootroot00000000000000cli-docs-3.1.0/.github/workflows/main.yml000066400000000000000000000006771506501313300202630ustar00rootroot00000000000000name: main on: push: branches: [main] tags: [v*] pull_request: branches: [main] jobs: test: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] go: [stable, oldstable] runs-on: ${{ matrix.os }} steps: - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - uses: actions/checkout@v4 with: fetch-depth: 0 - run: make cli-docs-3.1.0/.gitignore000066400000000000000000000001561506501313300151770ustar00rootroot00000000000000*.coverprofile *.exe *.orig .*envrc .envrc .idea /.local/ /site/ coverage.txt internal/*/built-example vendor cli-docs-3.1.0/.golangci.yaml000066400000000000000000000001421506501313300157270ustar00rootroot00000000000000# https://golangci-lint.run/usage/configuration/ linters: enable: - makezero - misspell cli-docs-3.1.0/CODE_OF_CONDUCT.md000066400000000000000000000063041506501313300160070ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting urfave-governance@googlegroups.com, a members-only group that is world-postable. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org cli-docs-3.1.0/LICENSE000066400000000000000000000020671506501313300142170ustar00rootroot00000000000000MIT License Copyright (c) 2023 urfave/cli maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cli-docs-3.1.0/Makefile000066400000000000000000000003221506501313300146420ustar00rootroot00000000000000.PHONY: all all: vet test show-cover .PHONY: vet vet: go vet -v ./... .PHONY: test test: go test -v -cover -coverprofile=coverage.txt ./... .PHONY: show-cover show-cover: go tool cover -func=coverage.txt cli-docs-3.1.0/README.md000066400000000000000000000032231506501313300144640ustar00rootroot00000000000000# Welcome to urfave/cli-docs/v3 [![Run Tests](https://github.com/urfave/cli-docs/actions/workflows/main.yml/badge.svg)](https://github.com/urfave/cli-docs/actions/workflows/main.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli-docs/v3.svg)](https://pkg.go.dev/github.com/urfave/cli-docs/v3) [![Go Report Card](https://goreportcard.com/badge/github.com/urfave/cli-docs/v3)](https://goreportcard.com/report/github.com/urfave/cli-docs/v3) urfave/cli-docs/v3 is an extended documentation library for use with urfave/cli/v3. ## Start using 1. Add the dependency to your project ```sh go get github.com/urfave/cli-docs/v3@latest ``` 2. Add it as import ```diff import ( + docs "github.com/urfave/cli-docs/v3" ) ``` 3. Now use it e.g. to generate markdown document from a command ```go package main import ( "context" "fmt" "os" docs "github.com/urfave/cli-docs/v3" cli "github.com/urfave/cli/v3" ) func main() { app := &cli.Command{ Name: "greet", Usage: "say a greeting", Action: func(ctx context.Context, c *cli.Command) error { fmt.Println("Greetings") return nil }, } md, err := docs.ToMarkdown(app) if err != nil { panic(err) } fi, err := os.Create("cli-docs.md") if err != nil { panic(err) } defer fi.Close() if _, err := fi.WriteString("# CLI\n\n" + md); err != nil { panic(err) } } ``` This will create a file `cli-docs.md` with content: ````md # CLI # NAME greet - say a greeting # SYNOPSIS greet **Usage**: ``` greet [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...] ``` ```` cli-docs-3.1.0/docs.go000066400000000000000000000344251506501313300144740ustar00rootroot00000000000000package docs import ( "bytes" _ "embed" "fmt" "io" "os" "reflect" "regexp" "runtime" "sort" "strconv" "strings" "text/template" "unicode/utf8" "github.com/cpuguy83/go-md2man/v2/md2man" "github.com/urfave/cli/v3" ) var ( //go:embed markdown.md.gotmpl MarkdownDocTemplate string //go:embed markdown_tabular.md.gotmpl MarkdownTabularDocTemplate string isTracingOn = os.Getenv("URFAVE_CLI_TRACING") == "on" ) func tracef(format string, a ...any) { if !isTracingOn { return } if !strings.HasSuffix(format, "\n") { format = format + "\n" } pc, file, line, _ := runtime.Caller(1) cf := runtime.FuncForPC(pc) fmt.Fprintf( os.Stderr, strings.Join([]string{ "## URFAVE CLI TRACE ", file, ":", fmt.Sprintf("%v", line), " ", fmt.Sprintf("(%s)", cf.Name()), " ", format, }, ""), a..., ) } // ToTabularMarkdown creates a tabular markdown documentation for // the `*cli.Command`. The function errors if either parsing or // writing of the string fails. func ToTabularMarkdown(cmd *cli.Command, appPath string) (string, error) { if appPath == "" { appPath = "app" } const name = "cli" t, err := template.New(name).Funcs(template.FuncMap{ "join": strings.Join, }).Parse(MarkdownTabularDocTemplate) if err != nil { return "", err } var ( w bytes.Buffer tt tabularTemplate ) if err = t.ExecuteTemplate(&w, name, cliTabularAppTemplate{ AppPath: appPath, Name: cmd.Name, Description: tt.PrepareMultilineString(cmd.Description), Usage: tt.PrepareMultilineString(cmd.Usage), UsageText: strings.FieldsFunc(cmd.UsageText, func(r rune) bool { return r == '\n' }), ArgsUsage: tt.PrepareMultilineString(cmd.ArgsUsage), GlobalFlags: tt.PrepareFlags(cmd.VisibleFlags()), Commands: tt.PrepareCommands(cmd.VisibleCommands(), appPath, "", 0), }); err != nil { return "", err } return tt.Prettify(w.String()), nil } // ToTabularToFileBetweenTags creates a tabular markdown documentation for the `*App` and updates the file between // the tags in the file. The function errors if either parsing or writing of the string fails. func ToTabularToFileBetweenTags(cmd *cli.Command, appPath, filePath string, startEndTags ...string) error { var start, end = "", "" // default tags if len(startEndTags) == 2 { start, end = startEndTags[0], startEndTags[1] } // read original file content content, err := os.ReadFile(filePath) if err != nil { return err } // generate markdown md, err := ToTabularMarkdown(cmd, appPath) if err != nil { return err } // prepare regexp to replace content between start and end tags re, err := regexp.Compile("(?s)" + regexp.QuoteMeta(start) + "(.*?)" + regexp.QuoteMeta(end)) if err != nil { return err } const comment = "" // replace content between start and end tags updated := re.ReplaceAll(content, []byte(strings.Join([]string{start, comment, md, end}, "\n"))) // write updated content to file if err = os.WriteFile(filePath, updated, 0664); err != nil { return err } return nil } // ToMarkdown creates a markdown string for the `*cli.Command` // The function errors if either parsing or writing of the string fails. func ToMarkdown(cmd *cli.Command) (string, error) { var w bytes.Buffer if err := writeDocTemplate(cmd, &w, 0); err != nil { return "", err } return w.String(), nil } // ToMan creates a man page string with section number for the // `*cli.Command` The function errors if either parsing or writing // of the string fails. func ToManWithSection(cmd *cli.Command, sectionNumber int) (string, error) { var w bytes.Buffer if err := writeDocTemplate(cmd, &w, sectionNumber); err != nil { return "", err } man := md2man.Render(w.Bytes()) return string(man), nil } // ToMan creates a man page string for the `*cli.Command` // The function errors if either parsing or writing of the string fails. func ToMan(cmd *cli.Command) (string, error) { man, err := ToManWithSection(cmd, 8) return man, err } type cliCommandTemplate struct { Command *cli.Command SectionNum int Commands []string GlobalArgs []string SynopsisArgs []string } func writeDocTemplate(cmd *cli.Command, w io.Writer, sectionNum int) error { tracef("using MarkdownDocTemplate starting %[1]q", string([]byte(MarkdownDocTemplate)[0:8])) const name = "cli" t, err := template.New(name).Parse(MarkdownDocTemplate) if err != nil { return err } return t.ExecuteTemplate(w, name, &cliCommandTemplate{ Command: cmd, SectionNum: sectionNum, Commands: prepareCommands(cmd.Commands, 0), GlobalArgs: prepareArgsWithValues(cmd.VisibleFlags()), SynopsisArgs: prepareArgsSynopsis(cmd.VisibleFlags()), }) } func prepareCommands(commands []*cli.Command, level int) []string { var coms []string for _, command := range commands { if command.Hidden { continue } usageText := prepareUsageText(command) usage := prepareUsage(command, usageText) prepared := fmt.Sprintf("%s %s\n\n%s%s", strings.Repeat("#", level+2), strings.Join(command.Names(), ", "), usage, usageText, ) flags := prepareArgsWithValues(command.VisibleFlags()) if len(flags) > 0 { prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n")) } coms = append(coms, prepared) // recursively iterate subcommands if len(command.Commands) > 0 { coms = append( coms, prepareCommands(command.Commands, level+1)..., ) } } return coms } func prepareArgsWithValues(flags []cli.Flag) []string { return prepareFlags(flags, ", ", "**", "**", `""`, true) } func prepareArgsSynopsis(flags []cli.Flag) []string { return prepareFlags(flags, "|", "[", "]", "[value]", false) } func prepareFlags( flags []cli.Flag, sep, opener, closer, value string, addDetails bool, ) []string { args := []string{} for _, f := range flags { flag, ok := f.(cli.DocGenerationFlag) if !ok { continue } modifiedArg := opener for _, s := range f.Names() { trimmed := strings.TrimSpace(s) if len(modifiedArg) > len(opener) { modifiedArg += sep } if len(trimmed) > 1 { modifiedArg += fmt.Sprintf("--%s", trimmed) } else { modifiedArg += fmt.Sprintf("-%s", trimmed) } } modifiedArg += closer if flag.TakesValue() { modifiedArg += fmt.Sprintf("=%s", value) } if addDetails { modifiedArg += flagDetails(flag) } args = append(args, modifiedArg+"\n") } sort.Strings(args) return args } // flagDetails returns a string containing the flags metadata func flagDetails(flag cli.DocGenerationFlag) string { description := flag.GetUsage() value := getFlagDefaultValue(flag) if value != "" { description += " (default: " + value + ")" } return ": " + description } func prepareUsageText(command *cli.Command) string { if command.UsageText == "" { return "" } // Remove leading and trailing newlines preparedUsageText := strings.Trim(command.UsageText, "\n") var usageText string if strings.Contains(preparedUsageText, "\n") { // Format multi-line string as a code block using the 4 space schema to allow for embedded markdown such // that it will not break the continuous code block. for _, ln := range strings.Split(preparedUsageText, "\n") { usageText += fmt.Sprintf(" %s\n", ln) } } else { // Style a single line as a note usageText = fmt.Sprintf(">%s\n", preparedUsageText) } return usageText } func prepareUsage(command *cli.Command, usageText string) string { if command.Usage == "" { return "" } usage := command.Usage + "\n" // Add a newline to the Usage IFF there is a UsageText if usageText != "" { usage += "\n" } return usage } type ( cliTabularAppTemplate struct { AppPath string Name string Usage string ArgsUsage string UsageText []string Description string GlobalFlags []cliTabularFlagTemplate Commands []cliTabularCommandTemplate } cliTabularCommandTemplate struct { AppPath string Name string Aliases []string Usage string ArgsUsage string UsageText []string Description string Category string Flags []cliTabularFlagTemplate SubCommands []cliTabularCommandTemplate Level uint } cliTabularFlagTemplate struct { Name string Aliases []string Usage string TakesValue bool Default string EnvVars []string Type string } ) // tabularTemplate is a struct for the tabular template preparation. type tabularTemplate struct{} // PrepareCommands converts CLI commands into a structs for the rendering. func (tt tabularTemplate) PrepareCommands(commands []*cli.Command, appPath, parentCommandName string, level uint) []cliTabularCommandTemplate { var result = make([]cliTabularCommandTemplate, 0, len(commands)) for _, cmd := range commands { var command = cliTabularCommandTemplate{ AppPath: appPath, Name: strings.TrimSpace(strings.Join([]string{parentCommandName, cmd.Name}, " ")), Aliases: cmd.Aliases, Usage: tt.PrepareMultilineString(cmd.Usage), UsageText: strings.FieldsFunc(cmd.UsageText, func(r rune) bool { return r == '\n' }), ArgsUsage: tt.PrepareMultilineString(cmd.ArgsUsage), Description: tt.PrepareMultilineString(cmd.Description), Category: cmd.Category, Flags: tt.PrepareFlags(cmd.VisibleFlags()), SubCommands: tt.PrepareCommands( // note: recursive call cmd.Commands, appPath, strings.Join([]string{parentCommandName, cmd.Name}, " "), level+1, ), Level: level, } result = append(result, command) } return result } // PrepareFlags converts CLI flags into a structs for the rendering. func (tt tabularTemplate) PrepareFlags(flags []cli.Flag) []cliTabularFlagTemplate { var result = make([]cliTabularFlagTemplate, 0, len(flags)) for _, appFlag := range flags { flag, ok := appFlag.(cli.DocGenerationFlag) if !ok { continue } var f = cliTabularFlagTemplate{ Usage: tt.PrepareMultilineString(flag.GetUsage()), EnvVars: flag.GetEnvVars(), TakesValue: flag.TakesValue(), Default: getFlagDefaultValue(flag), Type: flag.TypeName(), } if boolFlag, isBool := appFlag.(*cli.BoolFlag); isBool { f.Default = strconv.FormatBool(boolFlag.Value) } for i, name := range appFlag.Names() { name = strings.TrimSpace(name) if i == 0 { f.Name = "--" + name continue } if len(name) > 1 { name = "--" + name } else { name = "-" + name } f.Aliases = append(f.Aliases, name) } result = append(result, f) } return result } // PrepareMultilineString prepares a string (removes line breaks). func (tabularTemplate) PrepareMultilineString(s string) string { return strings.TrimRight( strings.TrimSpace( strings.ReplaceAll(s, "\n", " "), ), ".\r\n\t", ) } func (tabularTemplate) Prettify(s string) string { var max = func(x, y int) int { if x > y { return x } return y } var b strings.Builder // search for tables for _, rawTable := range regexp.MustCompile(`(?m)^(\|[^\n]+\|\r?\n)((?:\|:?-+:?)+\|)(\n(?:\|[^\n]+\|\r?\n?)*)?$`).FindAllString(s, -1) { var lines = strings.FieldsFunc(rawTable, func(r rune) bool { return r == '\n' }) if len(lines) < 3 { // header, separator, body continue } // parse table into the matrix var matrix = make([][]string, 0, len(lines)) for _, line := range lines { items := strings.FieldsFunc(strings.Trim(line, "| "), func(r rune) bool { return r == '|' }) for i := range items { items[i] = strings.TrimSpace(items[i]) // trim spaces in cells } matrix = append(matrix, items) } // determine centered columns var centered = make([]bool, 0, len(matrix[1])) for _, cell := range matrix[1] { centered = append(centered, strings.HasPrefix(cell, ":") && strings.HasSuffix(cell, ":")) } // calculate max lengths var lengths = make([]int, len(matrix[0])) for n, row := range matrix { for i, cell := range row { if n == 1 { continue // skip separator } if l := utf8.RuneCountInString(cell); l > lengths[i] { lengths[i] = l } } } // format cells for i, row := range matrix { for j, cell := range row { if i == 1 { // is separator if centered[j] { b.Reset() b.WriteRune(':') b.WriteString(strings.Repeat("-", max(0, lengths[j]))) b.WriteRune(':') row[j] = b.String() } else { row[j] = strings.Repeat("-", max(0, lengths[j]+2)) } continue } var ( cellWidth = utf8.RuneCountInString(cell) padLeft, padRight = 1, max(1, lengths[j]-cellWidth+1) // align to the left ) if centered[j] { // is centered padLeft = max(1, (lengths[j]-cellWidth)/2) padRight = max(1, lengths[j]-cellWidth-(padLeft-1)) } b.Reset() b.WriteString(strings.Repeat(" ", padLeft)) if padLeft+cellWidth+padRight <= lengths[j]+1 { b.WriteRune(' ') // add an extra space if the cell is not full } b.WriteString(cell) b.WriteString(strings.Repeat(" ", padRight)) row[j] = b.String() } } b.Reset() for _, row := range matrix { // build new table b.WriteRune('|') b.WriteString(strings.Join(row, "|")) b.WriteRune('|') b.WriteRune('\n') } s = strings.Replace(s, rawTable, b.String(), 1) } s = regexp.MustCompile(`\n{2,}`).ReplaceAllString(s, "\n\n") // normalize newlines s = strings.Trim(s, " \n") // trim spaces and newlines return s + "\n" // add an extra newline } // getFlagDefaultValue returns the default value of a flag. Previously, the [cli.DocGenerationFlag] interface included // a GetValue string method, but it was removed in https://github.com/urfave/cli/pull/1988. // This function serves as a workaround, attempting to retrieve the value using the removed method; if that fails, it // tries to obtain it via reflection (the [cli.FlagBase] still has a Value field). func getFlagDefaultValue(f cli.DocGenerationFlag) string { if !f.TakesValue() { return "" } if v, ok := f.(interface{ GetValue() string }); ok { return v.GetValue() } var ref = reflect.ValueOf(f) if ref.Kind() != reflect.Ptr { return "" } else { ref = ref.Elem() } if ref.Kind() != reflect.Struct { return "" } if val := ref.FieldByName("Value"); val.IsValid() && val.Type().Kind() != reflect.Bool { return fmt.Sprintf("%v", val.Interface()) } return "" } cli-docs-3.1.0/docs_test.go000066400000000000000000000236441506501313300155340ustar00rootroot00000000000000package docs import ( "bytes" "embed" "io" "io/fs" "net/mail" "os" "testing" "github.com/stretchr/testify/require" "github.com/urfave/cli/v3" ) var ( //go:embed testdata testdata embed.FS ) func expectFileContent(t *testing.T, file, got string) { data, err := testdata.ReadFile(file) r := require.New(t) r.NoError(err) r.Equal( string(normalizeNewlines([]byte(got))), string(normalizeNewlines(data)), ) } func normalizeNewlines(d []byte) []byte { return bytes.ReplaceAll( bytes.ReplaceAll( d, []byte("\r\n"), []byte("\n"), ), []byte("\r"), []byte("\n"), ) } func buildExtendedTestCommand() *cli.Command { return &cli.Command{ Writer: io.Discard, Name: "greet", Flags: []cli.Flag{ &cli.StringFlag{ Name: "socket", Aliases: []string{"s"}, Usage: "some 'usage' text", Value: "value", TakesFile: true, }, &cli.StringFlag{Name: "flag", Aliases: []string{"fl", "f"}}, &cli.BoolFlag{ Name: "another-flag", Aliases: []string{"b"}, Usage: "another usage text", Sources: cli.EnvVars("EXAMPLE_VARIABLE_NAME"), }, &cli.BoolFlag{ Name: "hidden-flag", Hidden: true, }, }, Commands: []*cli.Command{{ Aliases: []string{"c"}, Flags: []cli.Flag{ &cli.StringFlag{ Name: "flag", Aliases: []string{"fl", "f"}, TakesFile: true, }, &cli.BoolFlag{ Name: "another-flag", Aliases: []string{"b"}, Usage: "another usage text", }, }, Name: "config", Usage: "another usage test", Commands: []*cli.Command{{ Aliases: []string{"s", "ss"}, Flags: []cli.Flag{ &cli.StringFlag{Name: "sub-flag", Aliases: []string{"sub-fl", "s"}}, &cli.BoolFlag{ Name: "sub-command-flag", Aliases: []string{"s"}, Usage: "some usage text", }, }, Name: "sub-config", Usage: "another usage test", }}, }, { Aliases: []string{"i", "in"}, Name: "info", Usage: "retrieve generic information", }, { Name: "some-command", }, { Name: "hidden-command", Hidden: true, }, { Aliases: []string{"u"}, Flags: []cli.Flag{ &cli.StringFlag{ Name: "flag", Aliases: []string{"fl", "f"}, TakesFile: true, }, &cli.BoolFlag{ Name: "another-flag", Aliases: []string{"b"}, Usage: "another usage text", }, }, Name: "usage", Usage: "standard usage text", UsageText: ` Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ` + "```" + ` func() { ... } ` + "```" + ` Should be a part of the same code block `, Commands: []*cli.Command{{ Aliases: []string{"su"}, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "sub-command-flag", Aliases: []string{"s"}, Usage: "some usage text", }, }, Name: "sub-usage", Usage: "standard usage text", UsageText: "Single line of UsageText", }}, }}, UsageText: "app [first_arg] [second_arg]", Description: `Description of the application.`, Usage: "Some app", Authors: []any{ "Harrison ", &mail.Address{Name: "Oliver Allen", Address: "oliver@toyshop.com"}, }, } } func TestToMarkdownFull(t *testing.T) { cmd := buildExtendedTestCommand() res, err := ToMarkdown(cmd) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-full.md", res) } func TestToTabularMarkdown(t *testing.T) { app := buildExtendedTestCommand() t.Run("full", func(t *testing.T) { res, err := ToTabularMarkdown(app, "app") require.NoError(t, err) expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res) }) t.Run("with empty path", func(t *testing.T) { res, err := ToTabularMarkdown(app, "") require.NoError(t, err) expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res) }) t.Run("with custom app path", func(t *testing.T) { res, err := ToTabularMarkdown(app, "/usr/local/bin") require.NoError(t, err) expectFileContent(t, "testdata/expected-tabular-markdown-custom-app-path.md", res) }) } func TestToTabularMarkdownFailed(t *testing.T) { tpl := MarkdownTabularDocTemplate t.Cleanup(func() { MarkdownTabularDocTemplate = tpl }) MarkdownTabularDocTemplate = "{{ .Foo }}" app := buildExtendedTestCommand() res, err := ToTabularMarkdown(app, "") r := require.New(t) r.Error(err) r.Equal("", res) } func TestToTabularToFileBetweenTags(t *testing.T) { expectedDocs, fErr := testdata.ReadFile("testdata/expected-tabular-markdown-full.md") r := require.New(t) r.NoError(fErr) t.Run("default tags", func(t *testing.T) { tmpFile, err := os.CreateTemp("", "") r := require.New(t) r.NoError(err) t.Cleanup(func() { _ = os.Remove(tmpFile.Name()) }) _, err = tmpFile.WriteString(`# App readme file Some description Some other text`) r.NoError(err) _ = tmpFile.Close() r.NoError(ToTabularToFileBetweenTags(buildExtendedTestCommand(), "app", tmpFile.Name())) content, err := os.ReadFile(tmpFile.Name()) r.NoError(err) content = normalizeNewlines(content) expected := normalizeNewlines([]byte(`# App readme file Some description ` + string(expectedDocs) + ` Some other text`)) r.Equal(string(expected), string(content)) }) t.Run("custom tags", func(t *testing.T) { r := require.New(t) tmpFile, err := os.CreateTemp("", "") r.NoError(err) t.Cleanup(func() { _ = os.Remove(tmpFile.Name()) }) // cleanup _, err = tmpFile.WriteString(`# App readme file Some description foo_BAR|baz lorem+ipsum Some other text`) r.NoError(err) _ = tmpFile.Close() r.NoError(ToTabularToFileBetweenTags(buildExtendedTestCommand(), "app", tmpFile.Name(), "foo_BAR|baz", "lorem+ipsum")) content, err := os.ReadFile(tmpFile.Name()) r.NoError(err) content = normalizeNewlines(content) expected := normalizeNewlines([]byte(`# App readme file Some description foo_BAR|baz ` + string(expectedDocs) + ` lorem+ipsum Some other text`)) r.Equal(string(expected), string(content)) }) t.Run("missing file", func(t *testing.T) { r := require.New(t) tmpFile, err := os.CreateTemp("", "") r.NoError(err) _ = tmpFile.Close() r.NoError(os.Remove(tmpFile.Name())) err = ToTabularToFileBetweenTags(buildExtendedTestCommand(), "app", tmpFile.Name()) r.ErrorIs(err, fs.ErrNotExist) }) } func TestToMarkdown(t *testing.T) { t.Run("no flags", func(t *testing.T) { app := buildExtendedTestCommand() app.Flags = nil res, err := ToMarkdown(app) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-no-flags.md", res) }) t.Run("no commands", func(t *testing.T) { app := buildExtendedTestCommand() app.Commands = nil res, err := ToMarkdown(app) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-no-commands.md", res) }) t.Run("no authors", func(t *testing.T) { app := buildExtendedTestCommand() app.Authors = []any{} res, err := ToMarkdown(app) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-no-authors.md", res) }) t.Run("no usage text", func(t *testing.T) { app := buildExtendedTestCommand() app.UsageText = "" res, err := ToMarkdown(app) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-no-usagetext.md", res) }) } func TestToMan(t *testing.T) { app := buildExtendedTestCommand() res, err := ToMan(app) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-full.man", res) } func TestToManParseError(t *testing.T) { app := buildExtendedTestCommand() tmp := MarkdownDocTemplate t.Cleanup(func() { MarkdownDocTemplate = tmp }) MarkdownDocTemplate = "{{ .App.Name" _, err := ToMan(app) require.ErrorContains(t, err, "template: cli:1: unclosed action") } func TestToManWithSection(t *testing.T) { cmd := buildExtendedTestCommand() res, err := ToManWithSection(cmd, 8) require.NoError(t, err) expectFileContent(t, "testdata/expected-doc-full.man", res) } func Test_prepareUsageText(t *testing.T) { t.Run("no UsageText provided", func(t *testing.T) { cmd := &cli.Command{} res := prepareUsageText(cmd) require.Equal(t, "", res) }) t.Run("single line UsageText", func(t *testing.T) { cmd := &cli.Command{UsageText: "Single line usage text"} res := prepareUsageText(cmd) require.Equal(t, ">Single line usage text\n", res) }) t.Run("multiline UsageText", func(t *testing.T) { cmd := &cli.Command{ UsageText: ` Usage for the usage text - Should be a part of the same code block `, } res := prepareUsageText(cmd) require.Equal(t, ` Usage for the usage text - Should be a part of the same code block `, res) }) t.Run("multiline UsageText has formatted embedded markdown", func(t *testing.T) { cmd := &cli.Command{ UsageText: ` Usage for the usage text ` + "```" + ` func() { ... } ` + "```" + ` Should be a part of the same code block `, } res := prepareUsageText(cmd) require.Equal(t, ` Usage for the usage text `+"```"+` func() { ... } `+"```"+` Should be a part of the same code block `, res) }) } func Test_prepareUsage(t *testing.T) { t.Run("no Usage provided", func(t *testing.T) { cmd := &cli.Command{} res := prepareUsage(cmd, "") require.Equal(t, "", res) }) t.Run("simple Usage", func(t *testing.T) { cmd := &cli.Command{Usage: "simple usage text"} res := prepareUsage(cmd, "") require.Equal(t, cmd.Usage+"\n", res) }) t.Run("simple Usage with UsageText", func(t *testing.T) { cmd := &cli.Command{Usage: "simple usage text"} res := prepareUsage(cmd, "a non-empty string") require.Equal(t, cmd.Usage+"\n\n", res) }) } cli-docs-3.1.0/go.mod000066400000000000000000000005661506501313300143220ustar00rootroot00000000000000module github.com/urfave/cli-docs/v3 go 1.24.4 require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 github.com/stretchr/testify v1.10.0 github.com/urfave/cli/v3 v3.4.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) cli-docs-3.1.0/go.sum000066400000000000000000000026141506501313300143430ustar00rootroot00000000000000github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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.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= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= cli-docs-3.1.0/markdown.md.gotmpl000066400000000000000000000013061506501313300166520ustar00rootroot00000000000000{{if gt .SectionNum 0}}% {{ .Command.Name }} {{ .SectionNum }} {{end}}# NAME {{ .Command.Name }}{{ if .Command.Usage }} - {{ .Command.Usage }}{{ end }} # SYNOPSIS {{ .Command.Name }} {{ if .SynopsisArgs }} ``` {{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}``` {{ end }}{{ if .Command.Description }} # DESCRIPTION {{ .Command.Description }} {{ end }} **Usage**: ```{{ if .Command.UsageText }} {{ .Command.UsageText }} {{ else }} {{ .Command.Name }} [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...] {{ end }}``` {{ if .GlobalArgs }} # GLOBAL OPTIONS {{ range $v := .GlobalArgs }} {{ $v }}{{ end }} {{ end }}{{ if .Commands }} # COMMANDS {{ range $v := .Commands }} {{ $v }}{{ end }}{{ end -}} cli-docs-3.1.0/markdown_tabular.md.gotmpl000066400000000000000000000036751506501313300203770ustar00rootroot00000000000000{{ define "flags" }} | 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 }} {{- /**/ -}} | {{ 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 }} cli-docs-3.1.0/testdata/000077500000000000000000000000001506501313300150165ustar00rootroot00000000000000cli-docs-3.1.0/testdata/expected-doc-full.man000066400000000000000000000025271506501313300210250ustar00rootroot00000000000000.nh .TH greet 8 .SH NAME .PP greet - Some app .SH SYNOPSIS .PP greet .PP .RS .nf [--another-flag|-b] [--flag|--fl|-f]=[value] [--socket|-s]=[value] .fi .RE .SH DESCRIPTION .PP Description of the application. .PP \fBUsage\fP: .PP .RS .nf app [first_arg] [second_arg] .fi .RE .SH GLOBAL OPTIONS .PP \fB--another-flag, -b\fP: another usage text .PP \fB--flag, --fl, -f\fP="": .PP \fB--socket, -s\fP="": some 'usage' text (default: value) .SH COMMANDS .SH config, c .PP another usage test .PP \fB--another-flag, -b\fP: another usage text .PP \fB--flag, --fl, -f\fP="": .SS sub-config, s, ss .PP another usage test .PP \fB--sub-command-flag, -s\fP: some usage text .PP \fB--sub-flag, --sub-fl, -s\fP="": .SH info, i, in .PP retrieve generic information .SH some-command .SH usage, u .PP standard usage text .PP .RS .nf Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ``` func() { ... } ``` Should be a part of the same code block .fi .RE .PP \fB--another-flag, -b\fP: another usage text .PP \fB--flag, --fl, -f\fP="": .SS sub-usage, su .PP standard usage text .PP .RS .PP Single line of UsageText .RE .PP \fB--sub-command-flag, -s\fP: some usage text cli-docs-3.1.0/testdata/expected-doc-full.md000066400000000000000000000023101506501313300206400ustar00rootroot00000000000000# NAME greet - Some app # SYNOPSIS greet ``` [--another-flag|-b] [--flag|--fl|-f]=[value] [--socket|-s]=[value] ``` # DESCRIPTION Description of the application. **Usage**: ``` app [first_arg] [second_arg] ``` # GLOBAL OPTIONS **--another-flag, -b**: another usage text **--flag, --fl, -f**="": **--socket, -s**="": some 'usage' text (default: value) # COMMANDS ## config, c another usage test **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-config, s, ss another usage test **--sub-command-flag, -s**: some usage text **--sub-flag, --sub-fl, -s**="": ## info, i, in retrieve generic information ## some-command ## usage, u standard usage text Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ``` func() { ... } ``` Should be a part of the same code block **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-usage, su standard usage text >Single line of UsageText **--sub-command-flag, -s**: some usage text cli-docs-3.1.0/testdata/expected-doc-no-authors.md000066400000000000000000000023101506501313300217750ustar00rootroot00000000000000# NAME greet - Some app # SYNOPSIS greet ``` [--another-flag|-b] [--flag|--fl|-f]=[value] [--socket|-s]=[value] ``` # DESCRIPTION Description of the application. **Usage**: ``` app [first_arg] [second_arg] ``` # GLOBAL OPTIONS **--another-flag, -b**: another usage text **--flag, --fl, -f**="": **--socket, -s**="": some 'usage' text (default: value) # COMMANDS ## config, c another usage test **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-config, s, ss another usage test **--sub-command-flag, -s**: some usage text **--sub-flag, --sub-fl, -s**="": ## info, i, in retrieve generic information ## some-command ## usage, u standard usage text Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ``` func() { ... } ``` Should be a part of the same code block **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-usage, su standard usage text >Single line of UsageText **--sub-command-flag, -s**: some usage text cli-docs-3.1.0/testdata/expected-doc-no-commands.md000066400000000000000000000005551506501313300221220ustar00rootroot00000000000000# NAME greet - Some app # SYNOPSIS greet ``` [--another-flag|-b] [--flag|--fl|-f]=[value] [--socket|-s]=[value] ``` # DESCRIPTION Description of the application. **Usage**: ``` app [first_arg] [second_arg] ``` # GLOBAL OPTIONS **--another-flag, -b**: another usage text **--flag, --fl, -f**="": **--socket, -s**="": some 'usage' text (default: value) cli-docs-3.1.0/testdata/expected-doc-no-flags.md000066400000000000000000000017511506501313300214140ustar00rootroot00000000000000# NAME greet - Some app # SYNOPSIS greet # DESCRIPTION Description of the application. **Usage**: ``` app [first_arg] [second_arg] ``` # COMMANDS ## config, c another usage test **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-config, s, ss another usage test **--sub-command-flag, -s**: some usage text **--sub-flag, --sub-fl, -s**="": ## info, i, in retrieve generic information ## some-command ## usage, u standard usage text Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ``` func() { ... } ``` Should be a part of the same code block **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-usage, su standard usage text >Single line of UsageText **--sub-command-flag, -s**: some usage text cli-docs-3.1.0/testdata/expected-doc-no-usagetext.md000066400000000000000000000023551506501313300223320ustar00rootroot00000000000000# NAME greet - Some app # SYNOPSIS greet ``` [--another-flag|-b] [--flag|--fl|-f]=[value] [--socket|-s]=[value] ``` # DESCRIPTION Description of the application. **Usage**: ``` greet [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...] ``` # GLOBAL OPTIONS **--another-flag, -b**: another usage text **--flag, --fl, -f**="": **--socket, -s**="": some 'usage' text (default: value) # COMMANDS ## config, c another usage test **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-config, s, ss another usage test **--sub-command-flag, -s**: some usage text **--sub-flag, --sub-fl, -s**="": ## info, i, in retrieve generic information ## some-command ## usage, u standard usage text Usage for the usage text - formatted: Based on the specified ConfigMap and summon secrets.yml - list: Inspect the environment for a specific process running on a Pod - for_effect: Compare 'namespace' environment with 'local' ``` func() { ... } ``` Should be a part of the same code block **--another-flag, -b**: another usage text **--flag, --fl, -f**="": ### sub-usage, su standard usage text >Single line of UsageText **--sub-command-flag, -s**: some usage text cli-docs-3.1.0/testdata/expected-tabular-markdown-custom-app-path.md000066400000000000000000000071231506501313300254340ustar00rootroot00000000000000## CLI interface - greet Description of the application. Some app. > app [first_arg] [second_arg] Usage: ```bash $ /usr/local/bin [GLOBAL FLAGS] [COMMAND] [COMMAND FLAGS] [ARGUMENTS...] ``` Global flags: | 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`) another usage test. Usage: ```bash $ /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* | ### `config sub-config` subcommand (aliases: `s`, `ss`) another usage test. Usage: ```bash $ /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* | ### `info` command (aliases: `i`, `in`) retrieve generic information. Usage: ```bash $ /usr/local/bin [GLOBAL FLAGS] info [ARGUMENTS...] ``` ### `some-command` command Usage: ```bash $ /usr/local/bin [GLOBAL FLAGS] some-command [ARGUMENTS...] ``` ### `usage` command (aliases: `u`) standard usage text. > Usage for the usage text > - formatted: Based on the specified ConfigMap and summon secrets.yml > - list: Inspect the environment for a specific process running on a Pod > - for_effect: Compare 'namespace' environment with 'local' > ``` > func() { ... } > ``` > Should be a part of the same code block Usage: ```bash $ /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* | ### `usage sub-usage` subcommand (aliases: `su`) standard usage text. > Single line of UsageText Usage: ```bash $ /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* | cli-docs-3.1.0/testdata/expected-tabular-markdown-full.md000066400000000000000000000070061506501313300233540ustar00rootroot00000000000000## CLI interface - greet Description of the application. Some app. > app [first_arg] [second_arg] Usage: ```bash $ app [GLOBAL FLAGS] [COMMAND] [COMMAND FLAGS] [ARGUMENTS...] ``` Global flags: | 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`) another usage test. Usage: ```bash $ 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* | ### `config sub-config` subcommand (aliases: `s`, `ss`) another usage test. Usage: ```bash $ 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* | ### `info` command (aliases: `i`, `in`) retrieve generic information. Usage: ```bash $ app [GLOBAL FLAGS] info [ARGUMENTS...] ``` ### `some-command` command Usage: ```bash $ app [GLOBAL FLAGS] some-command [ARGUMENTS...] ``` ### `usage` command (aliases: `u`) standard usage text. > Usage for the usage text > - formatted: Based on the specified ConfigMap and summon secrets.yml > - list: Inspect the environment for a specific process running on a Pod > - for_effect: Compare 'namespace' environment with 'local' > ``` > func() { ... } > ``` > Should be a part of the same code block Usage: ```bash $ 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* | ### `usage sub-usage` subcommand (aliases: `su`) standard usage text. > Single line of UsageText Usage: ```bash $ 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* |