cli

package
v0.8.22 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Package cli implements the jokku command line: Dokku's commands, arguments and output, backed by the Jokku API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(ctx context.Context, args []string, stdio IO) int

Main runs the CLI with args (without the program name) and returns the exit code.

Types

type AppMode

type AppMode int

AppMode says how a command takes its app argument.

const (
	NoApp       AppMode = iota
	NeedsApp            // "<app>" is required
	AppOrGlobal         // "<app>" or --global
	OptionalApp         // "[<app>]"; reports cover every app without one
)

type Command

type Command struct {
	Name    string
	Args    string // usage after the app, e.g. "KEY=VALUE..."
	Help    string
	App     AppMode
	Flags   []Flag
	MinArgs int
	MaxArgs int // -1 for no limit
	// AnyFlags accepts arbitrary --flags; report commands use them to select
	// one value (apps:report myapp --app-locked).
	AnyFlags bool
	// PassArgsAfter stops flag parsing after this many positional
	// arguments (the app included), so the rest reach a command verbatim:
	// "jokku enter app web ls -la".
	PassArgsAfter int
	// Local commands run without an API connection.
	Local  bool
	Hidden bool
	Run    func(*Context) error
	// contains filtered or unexported fields
}

type Context

type Context struct {
	context.Context
	IO
	Cmd  *Command
	App  string
	Args []string
	API  *client.Client
	// contains filtered or unexported fields
}

func (*Context) Bool

func (c *Context) Bool(name string) bool

func (*Context) Global

func (c *Context) Global() bool

Global reports whether the command targets global settings instead of an app.

func (*Context) Header

func (c *Context) Header(format string, args ...any)

func (*Context) Info

func (c *Context) Info(format string, args ...any)

func (*Context) Step

func (c *Context) Step(format string, args ...any)

func (*Context) String

func (c *Context) String(name string) string

func (*Context) Warn

func (c *Context) Warn(format string, args ...any)

type Flag

type Flag struct {
	Name  string // long name without dashes
	Short string // optional single-letter alias
	Value string // placeholder when the flag takes a value; empty for booleans
	Help  string
}

type IO

type IO struct {
	Stdin          io.Reader
	Stdout, Stderr io.Writer
}

IO is where a command reads and writes.

type UsageError

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

UsageError is printed with the command's usage line.

func (*UsageError) Error

func (e *UsageError) Error() string

Jump to

Keyboard shortcuts

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