Documentation
¶
Overview ¶
Package cli is the cobra-based command surface for adept.
Composition root pattern: NewRoot wires every concrete implementation behind interfaces into a *Deps container, then attaches each subcommand constructed from that container. No package-level state. No init() side effects. Every command receives its dependencies explicitly so it can be tested with mocks.
Index ¶
- Variables
- func Context() context.Context
- func ExitFromError(err error) int
- func NewRoot(b BuildInfo) *cobra.Command
- func NewTabWriter(w io.Writer) *tabwriter.Writer
- type BuildInfo
- type Deps
- func (d *Deps) Library() (library.Library, error)
- func (d *Deps) LoadUserAdapters() error
- func (d *Deps) Print(w io.Writer, r Renderable) error
- func (d *Deps) PrintError(w io.Writer, err error)
- func (d *Deps) Project() (project.Project, error)
- func (d *Deps) ResolveLibraryRoot() (string, error)
- func (d *Deps) ResolveProjectRoot() (string, error)
- type GlobalFlags
- type Renderable
Constants ¶
This section is empty.
Variables ¶
var ( ErrSkillNotFound = adept.ErrSkillNotFound ErrSkillInvalid = adept.ErrSkillInvalid ErrLockSchemaMismatch = adept.ErrLockSchemaMismatch ErrBudgetOverflow = adept.ErrBudgetOverflow ErrAdapterInvalid = adept.ErrAdapterInvalid ErrHarnessUnknown = adept.ErrHarnessUnknown ErrMergeConflict = adept.ErrMergeConflict ErrMergeBaseMissing = adept.ErrMergeBaseMissing )
Surface for testing: re-export adept sentinels under the CLI package so command tests can `require.ErrorIs(err, cli.ErrSkillNotFound)` without an extra import.
var ErrDirty = errors.New("dirty state detected")
ErrDirty is the sentinel returned by commands that report drift but did not fail.
Functions ¶
func Context ¶
Context returns a request context for the duration of one command run. Centralizing this lets future versions wire signal handling or tracing.
func ExitFromError ¶
ExitFromError maps an error to an exit code.
- nil -> 0
- ErrDirty -> 2 (drift / dirty state, used by doctor/status)
- ErrMergeConflict -> 2 (resolve --strategy merge surfaced conflicts)
- any other err -> 1
Types ¶
type Deps ¶
type Deps struct {
Flags *GlobalFlags
Build BuildInfo
// Core
Parser canonical.Parser
Validator canonical.Validator
Loader canonical.Loader
Hasher hash.Hasher
Config config.Store
Status status.Resolver
Writer fsutil.Writer
Linker fsutil.Linker
Git git.Client
Log log.Logger
// Orchestration
Registry harness.Registry
Orchestrator harness.Orchestrator
AdapterLoader adapter.Loader
// Org + signing
OrgParser org.Parser
Verifier sign.Verifier
Signer sign.Signer
SignBackend sign.Backend
}
Deps is the dependency container.
Pure constructor injection — every collaborator is an interface, every field is read-only after construction. Commands receive a *Deps and resolve project/library roots per invocation so a single Deps instance services the whole CLI run.
func NewDeps ¶
func NewDeps(gf *GlobalFlags, b BuildInfo) (*Deps, error)
NewDeps wires concrete implementations. This is the only place where concrete types are mentioned — every downstream package consumes interfaces.
func (*Deps) LoadUserAdapters ¶
LoadUserAdapters reads adapter YAMLs from <library>/adapters/ and registers them. Best-effort: missing directory is not an error.
func (*Deps) Print ¶
func (d *Deps) Print(w io.Writer, r Renderable) error
Print writes the renderable to w using the global --json flag.
func (*Deps) PrintError ¶
PrintError emits an error in the configured format.
func (*Deps) ResolveLibraryRoot ¶
ResolveLibraryRoot returns --library, then $ADEPT_LIBRARY, then $HOME/.adeptability.
func (*Deps) ResolveProjectRoot ¶
ResolveProjectRoot returns --project or cwd.
type GlobalFlags ¶
GlobalFlags hold flags shared by every subcommand.