usage

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2019 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppHelpTemplate = `## NAME
**{{.HelpName}}** -- {{.Usage}}

## USAGE
{{if .UsageText}}{{.UsageText}}{{else}}**{{.HelpName}}**{{if .Commands}} <command>{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}_[arguments]_{{end}}{{end}}{{if .Description}}

## DESCRIPTION
{{.Description}}{{end}}{{if .VisibleCommands}}

## COMMANDS

{{range .VisibleCategories}}{{if .Name}}{{.Name}}:{{end}}
|||
|---|---|{{range .VisibleCommands}}
| **{{join .Names ", "}}** | {{.Usage}} |{{end}}
{{end}}{{if .VisibleFlags}}{{end}}

## OPTIONS

{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}
{{end}}{{end}}{{if .Copyright}}{{if len .Authors}}

## AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:

{{range $index, $author := .Authors}}{{if $index}}
{{end}}{{$author}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}

## ONLINE

This documentation is available online at https://smallstep.com/docs/cli

## VERSION

{{.Version}}{{end}}{{end}}

## COPYRIGHT

{{.Copyright}}

## FEEDBACK ` +
	html.UnescapeString("&#"+strconv.Itoa(128525)+";") + " " +
	html.UnescapeString("&#"+strconv.Itoa(127867)+";") +
	`

The **step** utility is not instrumented for usage statistics. It does not phone home.
But your feedback is extremely valuable. Any information you can provide regarding how you’re using **step** helps.
Please send us a sentence or two, good or bad: **feedback@smallstep.com** or join https://gitter.im/smallstep/community.
{{end}}
`

AppHelpTemplate contains the modified template for the main app

View Source
var CommandHelpTemplate = `` /* 403-byte string literal not displayed */

CommandHelpTemplate contains the modified template for a command

View Source
var HelpCommandAction = cli.ActionFunc(helpAction)

HelpCommandAction is the action function of the overwritten help command.

View Source
var SubcommandHelpTemplate = `` /* 531-byte string literal not displayed */

SubcommandHelpTemplate contains the modified template for a sub command Note that the weird "|||\n|---|---|" syntax sets up a markdown table with empty headers.

Functions

func FlagNamePrefixer

func FlagNamePrefixer(fullName, placeholder string) string

FlagNamePrefixer converts a full flag name and its placeholder into the help message flag prefix. This is used by the default FlagStringer.

This method clones urflave/cli functionality but adds a new line at the end.

func HelpCommand

func HelpCommand() cli.Command

HelpCommand overwrites default urfvafe/cli help command to support one or multiple subcommands like:

step help
step help crypto
step help crypto jwt
step help crypto jwt sign
...

func HelpPrinter

func HelpPrinter(w io.Writer, templ string, data interface{})

HelpPrinter overwrites cli.HelpPrinter and prints the formatted help to the terminal.

func Render

func Render(b []byte) []byte

Render renders the given data with a custom markdown renderer.

Types

type Argument

type Argument struct {
	Required bool
	Multiple bool
	Name     string
	Usage    string
}

Argument specifies the Name, Usage, and whether or not an Argument is required or not

func (Argument) Decorate

func (a Argument) Decorate() string

Decorate returns the name of an Argument and decorates it with notation to indicate whether its required or not

type Arguments

type Arguments []Argument

Arguments is an array of Argument structs that specify which arguments are accepted by a Command

func (Arguments) ArgsUsage

func (args Arguments) ArgsUsage() string

ArgsUsage returns the value of the ArgsUsage property for a cli.Command for these arguments

func (Arguments) UsageText

func (args Arguments) UsageText() string

UsageText returns the value of the UsageText property for a cli.Command for these arguments

type RenderMode

type RenderMode int

RenderMode enumerates different line breaks modes.

const (
	// RenderModeKeepBreaks will keep the line breaks in the docs.
	RenderModeKeepBreaks RenderMode = iota
	// RenderModeBreakLines will automatically wrap the lines.
	RenderModeBreakLines
)

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer implements a custom markdown renderer for blackfriday.

func (*Renderer) RenderFooter

func (r *Renderer) RenderFooter(w io.Writer, ast *md.Node)

RenderFooter implements blackfriday.Renderer interface.

func (*Renderer) RenderHeader

func (r *Renderer) RenderHeader(w io.Writer, ast *md.Node)

RenderHeader implements blackfriday.Renderer interface.

func (*Renderer) RenderNode

func (r *Renderer) RenderNode(w io.Writer, node *md.Node, entering bool) md.WalkStatus

RenderNode implements blackfriday.Renderer interface.

type Report added in v0.8.4

type Report struct {
	Report []*Section `json:"report"`
}

Report holds together a report of sections

func NewReport added in v0.8.4

func NewReport(command string, top []byte) *Report

NewReport returns report based on raw

func (*Report) PerHeadline added in v0.8.4

func (report *Report) PerHeadline(headline string) []Section

PerHeadline returns all sections across commands/pages with the same headline

func (*Report) Process added in v0.8.4

func (report *Report) Process(command string, raw []byte) error

Process adds a html based help page to the report

func (*Report) Write added in v0.8.4

func (report *Report) Write(w io.Writer) error

Write serializes the report to json

type Section added in v0.8.4

type Section struct {
	Command  string     `json:"command"`
	Name     string     `json:"name"`
	Text     string     `json:"text"`
	Words    int        `json:"words"`
	Lines    int        `json:"lines"`
	Sections []*Section `json:"sections"`
}

Section keeps track of individual sections

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL