Documentation
¶
Index ¶
Constants ¶
const DefaultName = "default"
DefaultName is the reserved synthetic profile that points at ~/.claude (Claude Code's default config dir when CLAUDE_CONFIG_DIR is unset).
Variables ¶
var ( // ErrInvalidName is returned when a profile name fails validation. ErrInvalidName = errors.New("invalid profile name") // ErrReservedName is returned when a caller tries to use a reserved name ErrReservedName = errors.New("reserved profile name") )
var ( // ErrNotFound is returned when a profile name is not in the store. ErrNotFound = errors.New("profile not found") // ErrAlreadyExists is returned by Add when a profile with the given name is already registered. ErrAlreadyExists = errors.New("profile already exists") )
Functions ¶
func ClaudeDir ¶
ClaudeDir returns the directory for a named profile.
macOS, Linux: $HOME/.claude-<name> Windows: %USERPROFILE%\.claude-<name>
func DefaultClaudeDir ¶
DefaultClaudeDir returns the path Claude Code uses when CLAUDE_CONFIG_DIR is unset: $HOME/.claude (or %USERPROFILE%\.claude). Used by `ccswitch list` to report the synthetic "default" row's existence.
func IsReserved ¶
IsReserved reports whether name is reserved by ccswitch and cannot be used
func MetadataPath ¶
MetadataPath returns the path to ccswitch's profiles.json.
Linux: $XDG_CONFIG_HOME/ccswitch/profiles.json, falling back to $HOME/.config/ccswitch/profiles.json macOS: $HOME/.config/ccswitch/profiles.json Windows: %APPDATA%\ccswitch\profiles.json
func ValidateName ¶
ValidateName checks a profile name against the allowed pattern. Returns ErrInvalidName wrapped with a descriptive message on failure.
Types ¶
type Profile ¶
type Profile struct {
Name string `json:"name"`
// Dir is stored as an absolute path so profiles survive $HOME changes.
Dir string `json:"dir"`
CreatedAt time.Time `json:"created_at"`
}
Profile is a user-created profile entry persisted in profiles.json.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the in-memory representation of profiles.json.
func Load ¶
Load reads profiles.json from path. A missing file is not an error — it returns an empty store rooted at path, ready for Save to create the file.
func (*Store) Add ¶
Add appends a new profile. Returns ErrAlreadyExists if a profile with the same name is already registered.