Skip to content

Extended documentation library for use with urfave/cli/v3

License

Notifications You must be signed in to change notification settings

urfave/cli-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

31c0a70 · Nov 6, 2024
Nov 4, 2024
Jun 24, 2023
Jun 25, 2023
Nov 27, 2022
Mar 18, 2023
May 7, 2022
Jun 12, 2023
Jun 24, 2023
Jul 14, 2024
Nov 4, 2024
Jun 25, 2023
Nov 4, 2024
Nov 4, 2024
Jun 24, 2023
Jun 24, 2023

Repository files navigation

Welcome to urfave/cli-docs/v3

Run Tests Go Reference Go Report Card

urfave/cli-docs/v3 is an extended documentation library for use with urfave/cli/v3.

Start using

  1. Add the dependency to your project
 go get github.com/urfave/cli-docs/v3@latest
  1. Add it as import
 import (
+  docs "github.com/urfave/cli-docs/v3"
 )
  1. Now use it e.g. to generate markdown document from a command
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:

# CLI

# NAME

greet - say a greeting

# SYNOPSIS

greet

**Usage**:

```
greet [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...]
```