cmd

package
v0.0.0-...-604a4b6 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveInstanceAlias

func ActiveInstanceAlias() string

ActiveInstanceAlias is kept for compatibility; use ActiveProfileName.

func ActiveProfileName

func ActiveProfileName() string

ActiveProfileName returns the resolved profile name for the active command, if any.

func ApplyInstanceProfile

func ApplyInstanceProfile(alias string) error

ApplyInstanceProfile forwards to ApplyProfile (legacy name).

func ApplyProfile

func ApplyProfile(alias string) error

ApplyProfile merges profiles.<name>.{api,auth,token} (or legacy instances.<name>) into top-level keys.

func CheckAPIError

func CheckAPIError(_ *cobra.Command, err error)

CheckAPIError checks if an error is an API error and handles it appropriately

func EffectiveCurrentProfileName

func EffectiveCurrentProfileName() string

EffectiveCurrentProfileName returns current_profile, or legacy current_instance.

func EffectiveInstanceForConfigUpdate

func EffectiveInstanceForConfigUpdate(cmd *cobra.Command) string

EffectiveInstanceForConfigUpdate forwards to EffectiveProfileForConfigUpdate.

func EffectiveProfileForConfigUpdate

func EffectiveProfileForConfigUpdate(cmd *cobra.Command) string

EffectiveProfileForConfigUpdate resolves scope for config update: --for-profile, else active profile.

func Execute

func Execute()

func HandleError

func HandleError(cmd *cobra.Command, err error)

HandleError handles errors in command execution

func InstanceScopedPrefix

func InstanceScopedPrefix() string

InstanceScopedPrefix forwards to ProfileScopedPrefix.

func IsRefreshTokenExpired

func IsRefreshTokenExpired() (bool, error)

IsRefreshTokenExpired checks if the refresh token has expired

func IsTokenExpired

func IsTokenExpired() (bool, error)

IsTokenExpired checks if the access token has expired

func IsVerbose

func IsVerbose(level int) bool

IsVerbose returns true if the specified verbosity level is enabled

func ListInstanceAliases

func ListInstanceAliases() []string

ListInstanceAliases forwards to ListProfileNames.

func ListProfileNames

func ListProfileNames() []string

ListProfileNames returns sorted profile names from profiles, or from instances if profiles is absent/empty.

func LoadConfig

func LoadConfig() (apiKey, baseURL, apiVersion string, err error)

func MergeProfileStorageRootForWrite

func MergeProfileStorageRootForWrite() string

MergeProfileStorageRootForWrite chooses "profiles" vs "instances" when adding a profile to an existing file.

func PrintErrorSummary

func PrintErrorSummary(errorList []error)

PrintErrorSummary prints a summary of errors for batch operations

func ProfileScopedPrefix

func ProfileScopedPrefix() string

ProfileScopedPrefix returns "profiles.<name>." or "instances.<name>." when a named profile is active.

func Prompt

func Prompt(message string, mask bool) (string, error)

Prompt reads input from the user with optional masking

func ReAuthenticate

func ReAuthenticate() error

ReAuthenticate re-authenticates using stored email from config and prompts for password

func RefreshAccessToken

func RefreshAccessToken() error

RefreshAccessToken refreshes the access token using the refresh token

func ResolveActiveInstanceAlias

func ResolveActiveInstanceAlias(cmd *cobra.Command) string

ResolveActiveInstanceAlias is kept for compatibility.

func ResolveActiveProfileName

func ResolveActiveProfileName(cmd *cobra.Command) string

ResolveActiveProfileName resolves: --profile, then current_profile / CYVER_PROFILE, then legacy current_instance / CYVER_INSTANCE.

func ResolveAndApplyInstance

func ResolveAndApplyInstance(cmd *cobra.Command) error

ResolveAndApplyInstance forwards to ResolveAndApplyProfile.

func ResolveAndApplyProfile

func ResolveAndApplyProfile(cmd *cobra.Command) error

ResolveAndApplyProfile sets activeProfileResolved and merges the selected profile into top-level viper keys. If the resolved name is not present in the config (stale current_profile / CYVER_PROFILE / --profile), the CLI continues with top-level keys only and does not fail, so commands like config init still work.

func RetryableErrorHandler

func RetryableErrorHandler(_ *cobra.Command, err error, attempt int, maxAttempts int) bool

RetryableErrorHandler handles retryable errors with user feedback

func SetAPIFieldForInstance

func SetAPIFieldForInstance(field string, value interface{}, forInstance string)

SetAPIFieldForInstance forwards to SetAPIFieldForProfile.

func SetAPIFieldForProfile

func SetAPIFieldForProfile(field string, value interface{}, forProfile string)

SetAPIFieldForProfile sets api.<field> and, when forProfile is set, <root>.<name>.api.<field>.

func SetAuthFieldForInstance

func SetAuthFieldForInstance(field string, value interface{}, forInstance string)

SetAuthFieldForInstance forwards to SetAuthFieldForProfile.

func SetAuthFieldForProfile

func SetAuthFieldForProfile(field string, value interface{}, forProfile string)

SetAuthFieldForProfile sets auth.<field> and nested profile auth when applicable.

func SetAuthViperKey

func SetAuthViperKey(suffix string, value interface{})

SetAuthViperKey writes auth fields under the active profile and mirrors to top-level auth.*.

func SetTokenViperKey

func SetTokenViperKey(suffix string, value interface{})

SetTokenViperKey writes token fields under the active profile and mirrors to top-level token.*.

func StoreToken

func StoreToken(tokenResp *v2_2.AuthenticateResultModel, filePath string) error

StoreToken saves the token response to a file with 0600 permissions

func UpdateConfig

func UpdateConfig(cmd *cobra.Command) error

UpdateConfig applies changed flags from the update command to viper and writes the config file.

func ValidateAndHandleErrors

func ValidateAndHandleErrors(_ *cobra.Command, data interface{})

ValidateAndHandleErrors validates input and handles any validation errors

func ValidateAndRefreshToken

func ValidateAndRefreshToken() error

ValidateAndRefreshToken validates the current token and refreshes it if necessary

Types

type ConfigLoader

type ConfigLoader struct{}

LoadConfig loads and validates the configuration file using Viper. It returns an error if the config file is missing, inaccessible, or lacks required fields. It also automatically validates and refreshes tokens if necessary. ConfigLoader implements the shared.ConfigLoader interface

func (*ConfigLoader) LoadConfig

func (c *ConfigLoader) LoadConfig() (apiKey, baseURL, apiVersion string, err error)

type CustomURLResponse

type CustomURLResponse struct {
	StatusCode int                 `json:"status_code"`
	Headers    map[string][]string `json:"headers"`
	Body       interface{}         `json:"body"`
	URL        string              `json:"url"`
	Method     string              `json:"method"`
	Duration   string              `json:"duration"`
}

CustomURLResponse represents the response structure for custom URL requests

func DirectHTTPRequest

func DirectHTTPRequest(method, urlPath, data string) (*CustomURLResponse, error)

DirectHTTPRequest performs a direct HTTP request with the specified method, URL, and data

type TokenInfo

type TokenInfo struct {
	AccessToken           string    `json:"access_token"`
	RefreshToken          string    `json:"refresh_token"`
	ExpiresIn             int32     `json:"expireInSeconds"`
	RefreshExpiresIn      int32     `json:"refresh_expires_in"`
	TokenCreatedAt        time.Time `json:"token_created_at"`
	RefreshTokenCreatedAt time.Time `json:"refresh_token_created_at"`
}

TokenInfo represents token information stored in config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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