Documentation
¶
Overview ¶
Package cli builds the gyro command tree: generated commands for every API operation (generated.go, from internal/spec) plus hand-written commands with nicer UX (server.go, ...).
Index ¶
- Constants
- Variables
- func Execute(a *App, args []string) int
- func NewRoot(a *App) *cobra.Command
- func ParseKV(pairs []string) (map[string]any, error)
- func PlanSlug(name string) string
- func Run(args []string) int
- func Slug(s string) string
- type App
- func (a *App) APIURL() string
- func (a *App) Client() (*api.Client, error)
- func (a *App) Config() (*config.File, error)
- func (a *App) Confirm(question string) error
- func (a *App) ConfirmTyped(question, word string) error
- func (a *App) Ctx() (context.Context, context.CancelFunc)
- func (a *App) Info(format string, args ...any)
- func (a *App) Machine() bool
- func (a *App) NewSpinner(label string) *Spinner
- func (a *App) PrintList(items []json.RawMessage, cols []output.Column, idPath string) error
- func (a *App) PrintRaw(raw json.RawMessage, cols []output.Column, idPath string) error
- func (a *App) Printer() *output.Printer
- func (a *App) Profile() *config.Profile
- func (a *App) ProfileName() string
- func (a *App) Prompt(r *bufio.Reader, label, def string) string
- func (a *App) ReadData(s string) (map[string]any, error)
- func (a *App) ReadValue(s string) (string, error)
- func (a *App) Token() (token, source string, err error)
- func (a *App) WaitFor(ctx context.Context, label string, timeout time.Duration, ...) error
- type ExitErr
- type Options
- type Spinner
Constants ¶
const ( ExitOK = 0 ExitError = 1 ExitUsage = 2 ExitAuth = 3 // 401/403 ExitNotFound = 4 ExitConflict = 5 // 409 ExitPayment = 6 // 402 ExitAborted = 7 // user said no / confirmation missing ExitRateLimit = 8 ExitTimeout = 9 // --wait timed out )
Exit codes (documented in README).
const LimitTicketCmd = `` /* 134-byte string literal not displayed */
LimitTicketCmd is the ticket command printed for limit refusals when the API does not send one.
Variables ¶
var ( Version = "dev" Commit = "none" Date = "unknown" )
Build information (set with -ldflags by GoReleaser).
var UpdateURL = "https://api.github.com/repos/Gyro-Hosting/gyro-cli/releases/latest"
UpdateURL is the GitHub "latest release" API endpoint (GYRO_UPDATE_URL overrides; "off" disables).
Functions ¶
func ParseKV ¶
ParseKV parses k=v pairs (values that look like JSON are decoded: numbers, true/false, [..], {..}).
Types ¶
type App ¶
type App struct {
Opt Options
In io.Reader
Out io.Writer
Err io.Writer
Env func(string) string
IsTTY func() bool // stdin is an interactive terminal (prompts allowed)
// NewClient can be replaced in tests.
NewClient func(baseURL, token string) *api.Client
// Sleep for --wait polling (tests set it to a no-op).
Sleep func(time.Duration)
// Exec runs external programs (ssh); tests replace it.
Exec func(name string, args []string) error
// contains filtered or unexported fields
}
App is shared by all commands.
func (*App) Confirm ¶
Confirm asks a yes/no question. --yes skips it; without a terminal it fails (exit 7) so scripts never spend money silently.
func (*App) ConfirmTyped ¶
ConfirmTyped makes the user type a word (e.g. the server name) before deleting.
func (*App) Ctx ¶
func (a *App) Ctx() (context.Context, context.CancelFunc)
Ctx returns a context cancelled on Ctrl-C and after --timeout.
func (*App) NewSpinner ¶
func (*App) ReadValue ¶
ReadValue loads @file / @- values for string flags (user data, public keys).