cmd

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 26 Imported by: 0

README

cli

Keyway Secrets

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBadgeToReadme

func AddBadgeToReadme(silent bool) (bool, error)

AddBadgeToReadme adds the Keyway badge to the README file Returns true if badge was added, false if already present or error

func EnsureLogin

func EnsureLogin() (string, error)

EnsureLogin ensures the user is logged in, prompting if necessary

func Execute

func Execute(ver string) error

Execute runs the root command

func FindReadmePath

func FindReadmePath(dir string) string

FindReadmePath looks for README.md in the given directory

func GenerateBadge

func GenerateBadge(repo string) string

GenerateBadge creates the markdown badge for a repository

func InsertBadgeIntoReadme

func InsertBadgeIntoReadme(content, badge string) string

InsertBadgeIntoReadme inserts the badge into README content

func RunConnectCommand

func RunConnectCommand(provider string) error

RunConnectCommand runs the connect command (for use by sync command)

func RunDeviceLogin

func RunDeviceLogin() (string, error)

RunDeviceLogin runs the device login flow and returns the token

Types

type APIClientFactory

type APIClientFactory interface {
	NewClient(token string) api.APIClient
}

APIClientFactory creates API clients

type AuthProvider

type AuthProvider interface {
	EnsureLogin() (string, error)
}

AuthProvider abstracts authentication for testing

type AuthStore

type AuthStore interface {
	GetAuth() (*StoredAuthInfo, error)
}

AuthStore abstracts auth storage for testing

type BrowserOpener

type BrowserOpener interface {
	OpenURL(url string) error
}

BrowserOpener abstracts browser operations for testing

type CommandRunner

type CommandRunner interface {
	RunCommand(name string, args []string, secrets map[string]string) error
}

CommandRunner abstracts command execution for testing

type Dependencies

type Dependencies struct {
	Git        GitClient
	Auth       AuthProvider
	UI         UIProvider
	FS         FileSystem
	Env        EnvHelper
	APIFactory APIClientFactory
	CmdRunner  CommandRunner
	Browser    BrowserOpener
	Walker     FileWalker
	Stat       FileStat
	AuthStore  AuthStore
	HTTP       HTTPClient
}

Dependencies holds all external dependencies for commands

func DefaultDeps

func DefaultDeps() *Dependencies

DefaultDeps returns the default (real) dependencies

type DiffEntry

type DiffEntry struct {
	Key      string `json:"key"`
	Value1   string `json:"value1,omitempty"`
	Value2   string `json:"value2,omitempty"`
	Preview1 string `json:"preview1,omitempty"`
	Preview2 string `json:"preview2,omitempty"`
}

type DiffOptions

type DiffOptions struct {
	Env1       string
	Env2       string
	ShowValues bool
	KeysOnly   bool
	JSONOutput bool
}

DiffOptions contains the parsed flags for the diff command

type DiffResult

type DiffResult struct {
	Env1       string      `json:"env1"`
	Env2       string      `json:"env2"`
	OnlyInEnv1 []string    `json:"onlyInEnv1"`
	OnlyInEnv2 []string    `json:"onlyInEnv2"`
	Different  []DiffEntry `json:"different"`
	Same       []string    `json:"same"`
	Stats      DiffStats   `json:"stats"`
}

DiffResult represents the comparison between two environments

type DiffStats

type DiffStats struct {
	TotalEnv1  int `json:"totalEnv1"`
	TotalEnv2  int `json:"totalEnv2"`
	OnlyInEnv1 int `json:"onlyInEnv1"`
	OnlyInEnv2 int `json:"onlyInEnv2"`
	Different  int `json:"different"`
	Same       int `json:"same"`
}

type DoctorOptions

type DoctorOptions struct {
	JSONOutput bool
	Strict     bool
	Version    string
}

DoctorOptions contains the parsed flags for the doctor command

type EnvCandidate

type EnvCandidate struct {
	File string
	Env  string
}

EnvCandidate represents a discovered env file

type EnvHelper

type EnvHelper interface {
	Discover() []EnvCandidate
	DeriveEnvFromFile(file string) string
}

EnvHelper abstracts env file operations for testing

type FileInfo

type FileInfo interface {
	Name() string
	IsDir() bool
	Size() int64
}

FileInfo abstracts os.FileInfo for testing

type FileStat

type FileStat interface {
	Stat(name string) (FileInfo, error)
}

FileStat abstracts os.Stat for testing

type FileSystem

type FileSystem interface {
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm uint32) error
}

FileSystem abstracts file operations for testing

type FileWalker

type FileWalker interface {
	Walk(root string, fn func(path string, info FileInfo, err error) error) error
}

FileWalker abstracts directory walking for testing

type Finding

type Finding struct {
	File    string `json:"file"`
	Line    int    `json:"line"`
	Type    string `json:"type"`
	Match   string `json:"match,omitempty"`
	Preview string `json:"preview"`
}

Finding represents a detected secret

type GitClient

type GitClient interface {
	DetectRepo() (string, error)
	CheckEnvGitignore() bool
	AddEnvToGitignore() error
	IsGitRepository() bool
	DetectMonorepo() MonorepoInfo
}

GitClient abstracts git operations for testing

type HTTPClient

type HTTPClient interface {
	Head(url string) (int, error)
}

HTTPClient abstracts HTTP operations for testing

type InitOptions

type InitOptions struct {
}

InitOptions contains the parsed flags for the init command

type MonorepoInfo added in v0.4.1

type MonorepoInfo struct {
	IsMonorepo bool
	Tool       string
}

MonorepoInfo contains information about detected monorepo setup

type ProjectWithLinkedRepo

type ProjectWithLinkedRepo struct {
	ID           string
	Name         string
	ServiceID    *string
	ServiceName  *string
	LinkedRepo   *string
	Environments []string
	ConnectionID string
	TeamID       *string
	TeamName     *string
}

ProjectWithLinkedRepo represents a provider project with metadata

type PullOptions

type PullOptions struct {
	EnvName    string
	File       string
	Yes        bool
	Force      bool
	EnvFlagSet bool
}

PullOptions contains the parsed flags for the pull command

type PushOptions

type PushOptions struct {
	EnvName    string
	File       string
	Yes        bool
	Prune      bool
	EnvFlagSet bool
}

PushOptions contains the parsed flags for the push command

type RunOptions

type RunOptions struct {
	EnvName    string
	EnvFlagSet bool
	Command    string
	Args       []string
}

RunOptions contains the parsed flags for the run command

type ScanResult

type ScanResult struct {
	FilesScanned int       `json:"filesScanned"`
	Findings     []Finding `json:"findings"`
}

ScanResult represents the complete scan output

type SecretPattern

type SecretPattern struct {
	Name        string
	Regex       *regexp.Regexp
	Description string
}

SecretPattern defines a pattern for detecting secrets

type SetOptions added in v0.5.0

type SetOptions struct {
	Key        string
	Value      string
	EnvName    string
	LocalOnly  bool
	Yes        bool
	EnvFlagSet bool
}

SetOptions contains the parsed flags for the set command

type StoredAuthInfo

type StoredAuthInfo struct {
	KeywayToken string
	GitHubLogin string
}

StoredAuthInfo contains stored authentication information

type UIProvider

type UIProvider interface {
	Intro(command string)
	Outro(message string)
	Success(message string)
	Error(message string)
	Warn(message string)
	Info(message string)
	Step(message string)
	Message(message string)
	IsInteractive() bool
	Confirm(message string, defaultValue bool) (bool, error)
	Select(message string, options []string) (string, error)
	Password(prompt string) (string, error)
	Spin(message string, fn func() error) error
	Value(v interface{}) string
	File(path string) string
	Link(url string) string
	Command(cmd string) string
	Bold(text string) string
	Dim(text string) string
	DiffAdded(key string)
	DiffChanged(key string)
	DiffRemoved(key string)
	DiffKept(key string)
}

UIProvider abstracts UI operations for testing

Jump to

Keyboard shortcuts

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