Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 4.12 KB

File metadata and controls

82 lines (61 loc) · 4.12 KB
type Package Documentation
title CoreCLI cmd/core — the core binary
description The core developer CLI binary — explicit command wiring, config/doctor/help/pkg surfaces, ecosystem commands, grammar-generated help, and the artifact test suite
repo core/cli
module dappco.re/go/cli/cmd/core

cmd/core — the core binary

Command core is the Lethean/dAppCore developer CLI — build, lint, qa, and packaging tooling. It is its own Go module (dappco.re/go/cli/cmd/core) so binary-only dependencies (go-i18n grammar, the build and lint modules and their transitive deps) stay out of the lean lib. Source: go/cmd/core/.

Wiring

main.go composes the surface explicitly — each command package exposes an AddXCommands(*core.Core) registrar handed to cli.WithCommands. Nothing is blank-imported for init() self-registration:

cli.Main(
    // Local CLI built-ins.
    cli.WithCommands("config", config.AddConfigCommands),
    cli.WithCommands("doctor", doctor.AddDoctorCommands),
    cli.WithCommands("help", help.AddHelpCommands),
    cli.WithCommands("pkg", pkgcmd.AddPkgCommands),

    // Ecosystem surface — core {build, go, qa}.
    cli.WithCommands("build", build.AddBuildCommands),  // dappco.re/go/build
    cli.WithCommands("go", gocmd.AddGoCommands),        // dappco.re/go/lint
    cli.WithCommands("qa", qa.AddQACommands),           // dappco.re/go/lint

    AddDemoActions,           // demo.echo action
    mountActionsWithGrammar,  // action registry → CLI, runs last so explicit commands win
)

Command surfaces

Package Commands
config config/get, config/set, config/list, config/path
doctor doctor, doctor/checks, doctor/commands, doctor/environment, doctor/install
help help
pkgcmd pkg/install, pkg/list, pkg/outdated, pkg/remove, pkg/search, pkg/update

Grammar-generated help

help_grammar.go keeps the go-i18n dependency in the binary — pkg/cli only knows the HelpGenerator func type. The generator composes a readable description from a dotted action name: last segment as the imperative action (title-cased), earlier segments as the definite-phrase subject, with go-i18n handling article elision, phonetics, and irregular forms:

grammarHelp("demo.echo")    // "Echo the demo"
grammarHelp("brain.recall") // "Recall the brain"

mountActionsWithGrammar passes it to cli.MountActions as the final setup, so explicit commands win any path collision.

Demo action

actions_demo.go registers demo.echo so core demo echo <text> exercises the capability-map → CLI projection end to end. Its own comment marks it as a harness demonstration: the wired ecosystem modules still expose functionality as explicit commands (they predate the action registry), so the file is deletable once those modules register their capabilities as actions.

Artifact tests (go/tests/cli/)

The AX-10 CLI integration suite validates the built binary as an artifact. Tasks build tests/cli/bin/cli, run it with real command-line arguments, and assert on stdout, stderr, and exit status from bash heredocs. Taskfile path = command path:

Taskfile Covers
tests/cli/Taskfile.yaml Artifact build and suite orchestration (task all)
tests/cli/config/Taskfile.yaml cli config ...
tests/cli/doctor/Taskfile.yaml cli doctor
tests/cli/pkg/search/Taskfile.yaml cli pkg search ...
tests/cli/version/Taskfile.yaml cli version

Tests isolate mutable state with temporary homes, registries, caches, and tool shims; commands that normally reach outside the sandbox (e.g. GitHub lookups) run from seeded fixtures.

File map

Path Contents
go/cmd/core/main.go Explicit wiring of all surfaces
go/cmd/core/help_grammar.go go-i18n HelpGenerator
go/cmd/core/actions_demo.go demo.echo projection demo
go/cmd/core/config/, doctor/, help/, pkgcmd/ Command packages, one registrar each
go/cmd/core/go.mod Binary module — grammar, build, lint deps live here
go/tests/cli/ Artifact validation Taskfiles