Documentation
¶
Index ¶
- Constants
- func ConfigDir() (string, error)
- func ConfigPath() (string, error)
- func EnvFromAPIKey(key string) (string, bool)
- func Execute() int
- func ExecuteWithArgs(args []string, out, errOut io.Writer) int
- func ExitCodeForHTTPStatus(status int) int
- func LatestAvailableVersion() (string, error)
- func NewRootCommand() *cobra.Command
- func RedactAPIKey(key string) string
- func RenderData(w io.Writer, contract Contract, data any) error
- func RenderError(w io.Writer, contract Contract, err error) int
- func SaveConfig(store ConfigStore) error
- func SetBuildInfo(v, c, b string)
- func SetOutput(cmd *cobra.Command, out, errOut io.Writer)
- func SetVersionInfo(v, c string)
- type AuthSource
- type CLIError
- type ConfigStore
- type Contract
- type DescribeArg
- type DescribeCommand
- type DescribeDocument
- type DescribeExample
- type DescribeExitCode
- type DescribeFlag
- type DescribeGeneratedFrom
- type DescribeInputField
- type DescribeOpenAPIOperation
- type DescribeOpenAPISnapshot
- type DoctorCheck
- type DoctorResult
- type OutputMode
- type ProfileStore
- type ResolvedAuth
- type SilentExitError
- type UpgradeResult
- type VersionInfo
Constants ¶
View Source
const ( EnvAuto = "auto" EnvLive = "live" EnvTest = "test" )
View Source
const ( ExitSuccess = iota ExitGeneric ExitUsage ExitValidation ExitAuthentication ExitForbidden ExitNotFound ExitConflict ExitRateLimited ExitNetwork )
View Source
const DefaultProfile = "default"
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
func EnvFromAPIKey ¶
func ExitCodeForHTTPStatus ¶
func LatestAvailableVersion ¶
func NewRootCommand ¶
func RedactAPIKey ¶
func SaveConfig ¶
func SaveConfig(store ConfigStore) error
func SetBuildInfo ¶
func SetBuildInfo(v, c, b string)
func SetVersionInfo ¶
func SetVersionInfo(v, c string)
SetVersionInfo is used by tests and build-time ldflags to override version metadata.
Types ¶
type AuthSource ¶
type AuthSource string
const ( AuthSourceNone AuthSource = "none" AuthSourceFlag AuthSource = "flag" AuthSourceEnv AuthSource = "env" AuthSourceConfig AuthSource = "config" )
type CLIError ¶
type CLIError struct {
Envelope api.ApiErrorResponse
Exit int
Status int
Hint string
DocsURL string
// contains filtered or unexported fields
}
func NewAPIError ¶
func NewAPIError(status int, envelope api.ApiErrorResponse, hint, docsURL string) *CLIError
func NewLocalError ¶
type ConfigStore ¶
type ConfigStore struct {
CurrentProfile string `toml:"current_profile,omitempty" json:"current_profile,omitempty"`
Profiles map[string]ProfileStore `toml:"profiles,omitempty" json:"profiles"`
}
func LoadConfig ¶
func LoadConfig() (ConfigStore, error)
func NewConfigStore ¶
func NewConfigStore() ConfigStore
type DescribeArg ¶
type DescribeCommand ¶
type DescribeCommand struct {
Name string `json:"name"`
Path []string `json:"path"`
Use string `json:"use"`
Short string `json:"short,omitempty"`
Args []DescribeArg `json:"args"`
Flags []DescribeFlag `json:"flags"`
AcceptedInputFields []DescribeInputField `json:"accepted_input_fields"`
ExpectedOutputSchema any `json:"expected_output_schema,omitempty"`
ExitCodes []int `json:"exit_codes"`
Example DescribeExample `json:"example"`
}
type DescribeDocument ¶
type DescribeDocument struct {
SchemaVersion string `json:"schema_version"`
GeneratedFrom DescribeGeneratedFrom `json:"generated_from"`
ExitCodes []DescribeExitCode `json:"exit_codes"`
Commands []DescribeCommand `json:"commands"`
OpenAPI DescribeOpenAPISnapshot `json:"openapi"`
}
func BuildDescribeDocument ¶
func BuildDescribeDocument(root *cobra.Command) (DescribeDocument, error)
type DescribeExample ¶
type DescribeExample struct {
Command string `json:"command"`
}
type DescribeExitCode ¶
type DescribeFlag ¶
type DescribeGeneratedFrom ¶
type DescribeInputField ¶
type DescribeOpenAPIOperation ¶
type DescribeOpenAPIOperation struct {
OperationID string `json:"operation_id"`
Method string `json:"method"`
Path string `json:"path"`
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Inputs []DescribeInputField `json:"inputs"`
Output any `json:"output,omitempty"`
ExitCodes []int `json:"exit_codes"`
}
type DescribeOpenAPISnapshot ¶
type DescribeOpenAPISnapshot struct {
Title string `json:"title"`
Version string `json:"version"`
Operations []DescribeOpenAPIOperation `json:"operations"`
}
type DoctorCheck ¶
type DoctorResult ¶
type DoctorResult struct {
Checks []DoctorCheck `json:"checks"`
}
type OutputMode ¶
type OutputMode string
const ( OutputHuman OutputMode = "human" OutputJSON OutputMode = "json" OutputRaw OutputMode = "raw" )
func ResolveOutputMode ¶
func ResolveOutputMode(jsonFlag, rawFlag, stdoutIsTTY bool) OutputMode
type ProfileStore ¶
type ProfileStore struct {
APIKey string `toml:"api_key,omitempty" json:"api_key,omitempty"`
}
type ResolvedAuth ¶
type ResolvedAuth struct {
APIKey string `json:"-"`
Redacted string `json:"api_key,omitempty"`
Env string `json:"env"`
Profile string `json:"profile,omitempty"`
Source AuthSource `json:"source"`
}
func ResolveAuth ¶
func ResolveAuth(opts rootOptions) (ResolvedAuth, error)
type SilentExitError ¶
type SilentExitError struct {
Code int
}
func (SilentExitError) Error ¶
func (e SilentExitError) Error() string
type UpgradeResult ¶
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuiltAt string `json:"built_at"`
APIBase string `json:"api_base"`
LatestAvailable string `json:"latest_available"`
}
func BuildVersionInfo ¶
func BuildVersionInfo(apiBase string) VersionInfo
Click to show internal directories.
Click to hide internal directories.