spec

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInvalidAppSpecError

func NewInvalidAppSpecError(reason string) error

NewInvalidAppSpecError creates a new error indicating that an app spec is invalid.

func NewInvalidCommandSpecError

func NewInvalidCommandSpecError(reason string) error

NewInvalidCommandSpecError creates a new error indicating that a command spec is invalid.

Types

type App

type App struct {
	Name        string               `json:"name"             yaml:"name"`
	Description string               `json:"description"      yaml:"description"`
	Server      string               `json:"server,omitempty" yaml:"server,omitempty"`
	Auth        *provider.AuthScheme `json:"auth,omitempty"   yaml:"auth,omitempty"`
	Commands    []*Command           `json:"commands"         yaml:"commands"`
}

An App specifies a complete clic application.

func NewAppSpec

func NewAppSpec(content []byte) (*App, error)

NewAppSpec creates a new App from the provided spec.

func (App) Validate

func (app App) Validate() error

Validate validates an App spec.

type Command

type Command struct {
	Name        string            `json:"name"                  yaml:"name"`
	Description string            `json:"description"           yaml:"description"`
	Provider    provider.Provider `json:"-"                     yaml:"-"`
	Subcommands []*Command        `json:"subcommands,omitempty" yaml:"subcommands,omitempty"`
}

A Command specifes an action or a set of subcommands.

func NewCommandSpec

func NewCommandSpec(content []byte) (*Command, error)

NewCommandSpec creates a new Command from the provided spec.

func (*Command) CLICommand

func (c *Command) CLICommand() *cobra.Command

CLICommand creates a cobra command for this command.

func (*Command) MarshalJSON added in v0.6.0

func (c *Command) MarshalJSON() ([]byte, error)

MarshalJSON marshals the command to JSON, writing the provider's config under its type key (e.g. "rest") so the result round-trips back through parsing.

func (*Command) MarshalYAML added in v0.6.0

func (c *Command) MarshalYAML() (any, error)

MarshalYAML marshals the command to YAML, writing the provider's config under its type key (e.g. "rest") in a stable, human-friendly field order.

func (*Command) UnmarshalJSON

func (c *Command) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the specified JSON data into the command.

func (*Command) UnmarshalYAML

func (c *Command) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals the specified YAML data into the command.

func (*Command) Validate

func (c *Command) Validate() error

Validate validates a Command spec.

type Format added in v0.6.0

type Format int

Format identifies the kind of spec a document represents.

const (
	// FormatUnknown indicates the spec format could not be determined.
	FormatUnknown Format = iota

	// FormatClic indicates a native clic spec.
	FormatClic

	// FormatOpenAPI indicates an OpenAPI (or Swagger) spec.
	FormatOpenAPI
)

func DetectFormat added in v0.6.0

func DetectFormat(data []byte) Format

DetectFormat inspects spec content and reports whether it is an OpenAPI document or a native clic spec. OpenAPI is identified by a top-level "openapi" or "swagger" key; a clic spec by its "commands" or "name" keys.

func (Format) String added in v0.6.0

func (f Format) String() string

String returns a human-readable name for the format.

Jump to

Keyboard shortcuts

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