scope.go

 1package config
 2
 3import "fmt"
 4
 5// Scope determines which config file is targeted for read/write operations.
 6type Scope int
 7
 8const (
 9	// ScopeGlobal targets the global data config (~/.local/share/crush/crush.json).
10	ScopeGlobal Scope = iota
11	// ScopeWorkspace targets the workspace config (.crush/crush.json).
12	ScopeWorkspace
13)
14
15// String returns a human-readable label for the scope.
16func (s Scope) String() string {
17	switch s {
18	case ScopeGlobal:
19		return "global"
20	case ScopeWorkspace:
21		return "workspace"
22	default:
23		return fmt.Sprintf("Scope(%d)", int(s))
24	}
25}
26
27// ErrNoWorkspaceConfig is returned when a workspace-scoped write is
28// attempted on a ConfigStore that has no workspace config path.
29var ErrNoWorkspaceConfig = fmt.Errorf("no workspace config path configured")