Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v1.5.30 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(name string) error

Execute runs the root command as name, the command word the binary was invoked as. Help and error text is authored with the canonical "flashduty"; under any other name the tree's text and the returned error are rewritten to it, and cobra derives completion scripts from the root's name.

func RootForDump added in v1.3.15

func RootForDump() *cobra.Command

RootForDump returns the fully-populated root command so dev tooling (the internal/cmd/skilldoc generator/validator) can build the command dump in-process, without shelling out to `flashduty __dump-commands`.

func SetVersionInfo

func SetVersionInfo(version, commit, date string)

SetVersionInfo sets build-time version info from ldflags.

Types

type RunContext

type RunContext struct {
	Client  *flashduty.Client
	Cmd     *cobra.Command
	Args    []string
	Writer  io.Writer
	Printer output.Printer
	Format  output.Format
}

RunContext provides helpers for command execution. It is created by runCommand and passed to the command's handler function. Client is the typed go-flashduty SDK every command calls through.

func (*RunContext) PrintCappedList added in v1.5.18

func (ctx *RunContext) PrintCappedList(items any, cols []output.Column, count, page, limit, total int, hasNext bool) error

PrintCappedList is PrintList for an endpoint whose total stops at serverCountCap; hasNext is the response's has_next_page.

func (*RunContext) PrintList

func (ctx *RunContext) PrintList(items any, cols []output.Column, count, page, limit, total int) error

PrintList is PrintPage for a response that carried a total.

func (*RunContext) PrintPage added in v1.5.17

func (ctx *RunContext) PrintPage(items any, cols []output.Column, pg listPage) error

PrintPage prints items and then states how complete they are (see listPage).

func (*RunContext) Structured added in v1.3.1

func (ctx *RunContext) Structured() bool

Structured reports whether output should be a machine-readable dump (JSON or TOON) rather than the human table/detail view. Command handlers branch on this to suppress detail views, footers, and interactive prompts.

func (*RunContext) WriteRaw added in v1.3.4

func (ctx *RunContext) WriteRaw(body []byte) error

WriteRaw writes a non-JSON response body (e.g. a CSV/file download surfaced on Response.Raw by the *export endpoints) straight to the output writer, so shell redirection (`> file.csv`) captures the bytes verbatim instead of the canned "OK: POST ..." acknowledgment.

func (*RunContext) WriteResult

func (ctx *RunContext) WriteResult(message string)

WriteResult prints a success message as plain text or JSON.

func (*RunContext) WriteResultJSON added in v1.1.0

func (ctx *RunContext) WriteResultJSON(data any, humanMessage string) error

WriteResultJSON outputs structured data in JSON or TOON mode, or a human-readable message in table mode. JSON stays indented (byte-compatible with the legacy --json path); TOON routes through the SDK marshaller.

Source Files

Jump to

Keyboard shortcuts

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