cmd

package
v0.1.0-alpha.26 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.0-alpha.26" // x-release-please-version

Variables

View Source
var Command = cli.Command{
	Name:    "stl",
	Usage:   "CLI for the stainless API",
	Version: Version,
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:  "debug",
			Usage: "Enable debug logging",
		},
		&cli.StringFlag{
			Name:  "base-url",
			Usage: "Override the base URL for API requests",
		},
		&cli.StringFlag{
			Name:  "environment",
			Usage: "Set the environment for API requests",
		},
	},
	Commands: []*cli.Command{
		{
			Name: "auth",
			Commands: []*cli.Command{
				&authLogin,
				&authLogout,
				&authStatus,
			},
		},

		{
			Name: "workspace",
			Commands: []*cli.Command{
				&workspaceInit,
				&workspaceStatus,
			},
		},

		{
			Name: "projects",
			Commands: []*cli.Command{
				&projectsCreate,
				&projectsRetrieve,
				&projectsUpdate,
				&projectsList,
			},
		},

		{
			Name: "projects:branches",
			Commands: []*cli.Command{
				&projectsBranchesCreate,
				&projectsBranchesRetrieve,
			},
		},

		{
			Name: "projects:configs",
			Commands: []*cli.Command{
				&projectsConfigsRetrieve,
				&projectsConfigsGuess,
			},
		},

		{
			Name: "builds",
			Commands: []*cli.Command{
				&buildsCreate,
				&buildsRetrieve,
				&buildsList,
				&buildsCompare,
			},
		},

		{
			Name: "builds:diagnostics",
			Commands: []*cli.Command{
				&buildsDiagnosticsList,
			},
		},

		{
			Name: "builds:target_outputs",
			Commands: []*cli.Command{
				&buildsTargetOutputsRetrieve,
			},
		},

		{
			Name: "orgs",
			Commands: []*cli.Command{
				&orgsRetrieve,
				&orgsList,
			},
		},

		&mcpCommand,
		&devCommand,
	},
	EnableShellCompletion: true,
	HideHelpCommand:       true,
}
View Source
var ErrUserCancelled = errors.New("user cancelled")

Functions

func CheckInteractiveAndInitWorkspace

func CheckInteractiveAndInitWorkspace(cmd *cli.Command, projectName string)

CheckInteractiveAndInitWorkspace checks if running in interactive mode and prompts to init workspace if needed

func ColorizeJSON

func ColorizeJSON(input string, w io.Writer) string

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the directory where config files are stored

func GetFormKeyMap

func GetFormKeyMap() *huh.KeyMap

GetFormKeyMap returns the standard huh keymap used across all forms

func GetFormTheme

func GetFormTheme() *huh.Theme

GetFormTheme returns the standard huh theme used across all forms

func GetProjectName

func GetProjectName(cmd *cli.Command, flagName string) string

GetProjectName returns the project name from the command line flag or workspace config

func SError

func SError(indent int, format string, args ...any) string

func SInfo

func SInfo(indent int, format string, args ...any) string

func SProgress

func SProgress(indent int, format string, args ...any) string

func SProperty

func SProperty(indent int, key, msg string) string

func SSuccess

func SSuccess(indent int, format string, args ...any) string

func SWarn

func SWarn(indent int, format string, args ...any) string

func SaveAuthConfig

func SaveAuthConfig(config *AuthConfig) error

SaveAuthConfig saves the auth config to disk

func Spacer

func Spacer()

func ViewDiagnosticsPrint

func ViewDiagnosticsPrint(diagnostics []stainless.BuildDiagnosticListResponse) string

func ViewHelpMenu

func ViewHelpMenu() string

ViewHelpMenu creates a styled help menu inspired by huh help component

func ViewPipeline

func ViewPipeline(build *stainless.BuildObject, target stainless.Target) string

func ViewStepSymbol

func ViewStepSymbol(stepUnion any) string

Types

type AuthConfig

type AuthConfig struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	TokenType    string `json:"token_type"`
}

AuthConfig stores the OAuth credentials

func LoadAuthConfig

func LoadAuthConfig() (*AuthConfig, error)

LoadAuthConfig loads the auth config from disk

type BuildModel

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

BuildModel represents the bubbletea model for build monitoring

func NewBuildModel

func NewBuildModel(cc *apiCommandContext, ctx context.Context, fn func() (*stainless.BuildObject, error)) BuildModel

func (BuildModel) Init

func (m BuildModel) Init() tea.Cmd

func (BuildModel) Update

func (m BuildModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (BuildModel) View

func (m BuildModel) View() string

type Group

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

Group represents a nested logging group

func Error

func Error(format string, args ...any) Group

func Info

func Info(format string, args ...any) Group

func Progress

func Progress(format string, args ...any) Group

func Property

func Property(key, msg string) Group

func Success

func Success(format string, args ...any) Group

func Warn

func Warn(format string, args ...any) Group

func (Group) Error

func (g Group) Error(format string, args ...any) Group

func (Group) Info

func (g Group) Info(format string, args ...any) Group

func (Group) Progress

func (g Group) Progress(format string, args ...any) Group

func (Group) Property

func (g Group) Property(key, msg string) Group

func (Group) Success

func (g Group) Success(format string, args ...any) Group

func (Group) Warn

func (g Group) Warn(format string, args ...any) Group

type WorkspaceConfig

type WorkspaceConfig struct {
	Project         string `json:"project"`
	OpenAPISpec     string `json:"openapi_spec,omitempty"`
	StainlessConfig string `json:"stainless_config,omitempty"`

	ConfigPath string `json:"-"`
}

WorkspaceConfig stores workspace-level configuration

func NewWorkspaceConfig

func NewWorkspaceConfig(projectName, openAPISpec, stainlessConfig string) (*WorkspaceConfig, error)

func (*WorkspaceConfig) Find

func (config *WorkspaceConfig) Find() (bool, error)

Find searches for a stainless-workspace.json file starting from the current directory and moving up to parent directories until found or root is reached

func (*WorkspaceConfig) Load

func (config *WorkspaceConfig) Load(configPath string) error

func (*WorkspaceConfig) Save

func (config *WorkspaceConfig) Save() error

Jump to

Keyboard shortcuts

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