/
documentation.go
113 lines (91 loc) · 2.67 KB
/
documentation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package criocli
import (
"fmt"
"strings"
"github.com/urfave/cli/v2"
)
const markdownDocTemplate = `
[//]: <> "This file has been autogenerated, please do not edit"
% {{ .App.Name }} 8
# NAME
{{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }}
# SYNOPSIS
{{ .App.Name }}
{{ if .SynopsisArgs }}
` + "```" + `
{{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}` + "```" + `
{{ end }}{{ if .App.UsageText }}
# DESCRIPTION
{{ .App.UsageText }}
{{ end }}
**Usage**:
` + "```" + `
{{ .App.Name }} [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
` + "```" + `
{{ if .GlobalArgs }}
# GLOBAL OPTIONS
{{ range $v := .GlobalArgs }}
{{ $v }}{{ end }}
{{ end }}{{ if .Commands }}
# COMMANDS
{{ range $v := .Commands }}
{{ $v }}{{ end }}{{ end }}
## FILES
**crio.conf** (/etc/crio/crio.conf)
cri-o configuration file for all of the available command-line options for
the crio(8) program, but in a TOML format that can be more easily modified
and versioned.
**policy.json** (/etc/containers/policy.json)
Signature verification policy files are used to specify policy, e.g. trusted
keys, applicable when deciding whether to accept an image, or individual
signatures of that image, as valid.
**registries.conf** (/etc/containers/registries.conf)
Registry configuration file specifies registries which are consulted when
completing image names that do not include a registry or domain portion.
**storage.conf** (/etc/containers/storage.conf)
Storage configuration file specifies all of the available container storage
options for tools using shared container storage.
{{ with .App.Metadata.Env -}}
# ENVIRONMENT
All command-line options may also be specified as environment variables.
The options detailed in this section, however, can only be set via
environment variables.
{{ range $envname, $helptext := . -}}
**{{ $envname }}**: {{ $helptext }}
{{ end -}}
{{ end -}}
# SEE ALSO
crio.conf(5), crio.conf.d(5), oci-hooks(5), policy.json(5), registries.conf(5),
storage.conf(5)`
func man() *cli.Command {
return &cli.Command{
Name: "man",
Usage: "Generate the man page documentation.",
Action: func(c *cli.Context) error {
cli.MarkdownDocTemplate = markdownDocTemplate
res, err := c.App.ToMan()
if err != nil {
return err
}
fmt.Print(res)
return nil
},
}
}
func markdown() *cli.Command {
return &cli.Command{
Name: "markdown",
Aliases: []string{"md"},
Usage: "Generate the markdown documentation.",
Action: func(c *cli.Context) error {
cli.MarkdownDocTemplate = markdownDocTemplate
res, err := c.App.ToMarkdown()
if err != nil {
return err
}
fmt.Print(strings.TrimSpace(res))
fmt.Printf("\r\n")
return nil
},
}
}