diff --git a/Taskfile.yml b/Taskfile.yml index 6c557ed..d9a9f5e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,12 +1,18 @@ version: '3' -includes: - gui: ./cmd/lthn-desktop/Taskfile.yml - cli: ./cmd/core/Taskfile.yml - demo: ./cmd/core-demo/Taskfile.yml - ide: ./cmd/core-gui/Taskfile.yml - tasks: + cli:build: + desc: "Build the core CLI executable" + cmds: + - go build -o ./bin/core . + + cli:run: + desc: "Build and run the core CLI" + cmds: + - task: cli:build + - ./bin/core {{.CLI_ARGS}} + + test: desc: "Run all Go tests recursively for the entire project." cmds: @@ -53,4 +59,4 @@ tasks: i18n:validate: desc: "Validate i18n key usage across the codebase" cmds: - - go run ./cmd/i18n-validate ./... + - go run ./internal/tools/i18n-validate ./... diff --git a/cmd/Taskfile.yml b/cmd/Taskfile.yml deleted file mode 100644 index a8d1c45..0000000 --- a/cmd/Taskfile.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '3' - -tasks: - build: - summary: Builds the core executable - cmds: - - go build -o {{.TASKFILE_DIR}}/../bin/core {{.TASKFILE_DIR}}/.. - - build:dev: - summary: Builds and runs the core executable in development mode - cmds: - - go build -o {{.TASKFILE_DIR}}/../bin/core {{.TASKFILE_DIR}}/.. - - CORE_DEV_TOOLS="false" {{.TASKFILE_DIR}}/../bin/core diff --git a/cmd/i18n-validate/main.go b/internal/tools/i18n-validate/main.go similarity index 100% rename from cmd/i18n-validate/main.go rename to internal/tools/i18n-validate/main.go diff --git a/cmd/variants/ci.go b/internal/variants/ci.go similarity index 100% rename from cmd/variants/ci.go rename to internal/variants/ci.go diff --git a/cmd/variants/full.go b/internal/variants/full.go similarity index 100% rename from cmd/variants/full.go rename to internal/variants/full.go diff --git a/cmd/variants/minimal.go b/internal/variants/minimal.go similarity index 100% rename from cmd/variants/minimal.go rename to internal/variants/minimal.go diff --git a/cmd/variants/php.go b/internal/variants/php.go similarity index 100% rename from cmd/variants/php.go rename to internal/variants/php.go diff --git a/main.go b/main.go index b5cd903..38a51c3 100644 --- a/main.go +++ b/main.go @@ -4,11 +4,15 @@ import ( "fmt" "os" - "github.com/host-uk/core/cmd" + "github.com/host-uk/core/pkg/cli" + + // Build variants import commands via self-registration. + // See internal/variants/ for available variants: full, ci, php, minimal. + _ "github.com/host-uk/core/internal/variants" ) func main() { - if err := cmd.Execute(); err != nil { + if err := cli.Main(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/cmd/core.go b/pkg/cli/app.go similarity index 60% rename from cmd/core.go rename to pkg/cli/app.go index 94837f8..7a2e014 100644 --- a/cmd/core.go +++ b/pkg/cli/app.go @@ -1,65 +1,44 @@ -// Package cmd implements the core CLI application. -// -// The CLI provides commands for: -// - Multi-repo development workflows (dev) -// - AI agent task management (ai) -// - Go and PHP development tools (go, php) -// - Build and release automation (build, ci) -// - SDK validation and API compatibility (sdk) -// - Package and environment management (pkg, vm) -// - Documentation and testing (docs, test) -// - Environment health checks (doctor) -// - Repository setup and cloning (setup) -// -// Two build variants exist: -// - Default build: Full development toolset -// - CI build (-tags ci): Minimal release toolset -package cmd +package cli import ( "os" - "github.com/host-uk/core/pkg/cli" "github.com/host-uk/core/pkg/framework" + "github.com/host-uk/core/pkg/log" "github.com/spf13/cobra" - - // Build variants import commands via self-registration. - // See cmd/variants/ for available variants: full, ci, php, minimal. - _ "github.com/host-uk/core/cmd/variants" ) const ( - appName = "core" - appVersion = "0.1.0" + // AppName is the CLI application name. + AppName = "core" + // AppVersion is the CLI application version. + AppVersion = "0.1.0" ) - - -// Execute initialises and runs the CLI application. -// Commands are registered based on build tags (see core_ci.go and core_dev.go). -func Execute() error { +// Main initialises and runs the CLI application. +// This is the main entry point for the CLI. +func Main() error { // Initialise CLI runtime with services - if err := cli.Init(cli.Options{ - AppName: appName, - Version: appVersion, + if err := Init(Options{ + AppName: AppName, + Version: AppVersion, Services: []framework.Option{ - framework.WithName("i18n", cli.NewI18nService(cli.I18nOptions{})), - framework.WithName("log", cli.NewLogService(cli.LogOptions{ - Level: cli.LogLevelInfo, + framework.WithName("i18n", NewI18nService(I18nOptions{})), + framework.WithName("log", NewLogService(log.Options{ + Level: log.LevelInfo, })), }, }); err != nil { return err } - defer cli.Shutdown() + defer Shutdown() // Add completion command to the CLI's root - cli.RootCmd().AddCommand(completionCmd) + RootCmd().AddCommand(completionCmd) - return cli.Execute() + return Execute() } - // completionCmd generates shell completion scripts. var completionCmd = &cobra.Command{ Use: "completion [bash|zsh|fish|powershell]",