Documentation
¶
Overview ¶
Package man enables man page generation of command line apps build with github.com/spf13/cobra.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶ added in v1.4.18
Generate writes the man page, taking the given command as root, to a writer.
Example ¶
ExampleGenerate generates a single man page describing all commands and sub-commands.
package main
import (
"bytes"
"fmt"
"time"
"github.com/bpicode/fritzctl/man"
"github.com/spf13/cobra"
)
func main() {
root := cobra.Command{
Use: "myApp",
}
options := man.Options{
Header: man.Header{
Section: "1",
Manual: "myApp's man page",
Title: "myApp",
},
Origin: man.Origin{
Date: time.Date(2006, time.January, 1, 8, 0, 0, 0, time.UTC),
Source: "written by a monkey on a typewriter",
},
SeeAlso: []string{"strace(1)"},
}
buf := new(bytes.Buffer)
man.Generate(&root, &options, buf)
s := buf.String()
fmt.Println(s[0:26])
}
Output: .TH "myApp" "1" "Jan 2006"
Types ¶
type Header ¶
type Header struct {
// Man page title.
Title string
// Man page section.
// Use "1" for General commands.
// Use "2" for System calls.
// Use "3" for Library functions, covering in particular the C standard library.
// Use "4" for Special files (usually devices, those found in /dev) and drivers.
// Use "5" for File formats and conventions.
// Use "6" for Games and screensavers.
// Use "7" for Miscellanea.
// Use "8" for System administration commands and daemons.
Section string
// Manual title.
Manual string
}
Header conveys general data of the man page.
Click to show internal directories.
Click to hide internal directories.