feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// Cli is the CLI surface layer for the Core command tree.
|
|
|
|
|
// It reads commands from Core's registry and wires them to terminal I/O.
|
|
|
|
|
//
|
|
|
|
|
// Run the CLI:
|
|
|
|
|
//
|
fix: AX audit round 5 — full naming, Result returns throughout
Renames (via GoLand refactor):
- Option.K → Key, Option.V → Value
- Err.Op → Operation, Err.Msg → Message, Err.Err → Error
- CrashSystem.OS → OperatingSystem, Arch → Architecture
- TaskID → TaskIdentifier, TaskWithID → TaskWithIdentifier
- Ipc → IPC, BaseDir → BaseDirectory
- ServiceRuntime.Opts → Options
Return type changes:
- Options.Get, Config.Get → Result (was (any, bool))
- Embed.ReadDir → Result (was ([]fs.DirEntry, error))
- Translator.Translate, I18n.Translate → Result (was string)
Rule 6:
- data.go: propagate opts.Get failure, typed error for bad fs.FS
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 16:32:43 +00:00
|
|
|
// c := core.New(core.Options{{Key: "name", Value: "myapp"}})
|
2026-03-20 12:08:19 +00:00
|
|
|
// c.Command("deploy", handler)
|
|
|
|
|
// c.Cli().Run()
|
|
|
|
|
//
|
|
|
|
|
// The Cli resolves os.Args to a command path, parses flags,
|
|
|
|
|
// and calls the command's action with parsed options.
|
2026-03-18 01:43:03 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
|
|
import (
|
2026-03-20 12:17:30 +00:00
|
|
|
"io"
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
"os"
|
2026-03-18 01:43:03 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// Cli is the CLI surface for the Core command tree.
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
type Cli struct {
|
2026-03-20 12:08:19 +00:00
|
|
|
core *Core
|
2026-03-20 12:17:30 +00:00
|
|
|
output io.Writer
|
2026-03-20 12:08:19 +00:00
|
|
|
banner func(*Cli) string
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:17:30 +00:00
|
|
|
// Print writes to the CLI output (defaults to os.Stdout).
|
|
|
|
|
//
|
|
|
|
|
// c.Cli().Print("hello %s", "world")
|
|
|
|
|
func (cl *Cli) Print(format string, args ...any) {
|
2026-03-20 12:20:36 +00:00
|
|
|
Print(cl.output, format, args...)
|
2026-03-20 12:17:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetOutput sets the CLI output writer.
|
|
|
|
|
//
|
|
|
|
|
// c.Cli().SetOutput(os.Stderr)
|
|
|
|
|
func (cl *Cli) SetOutput(w io.Writer) {
|
|
|
|
|
cl.output = w
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// Run resolves os.Args to a command path and executes it.
|
|
|
|
|
//
|
|
|
|
|
// c.Cli().Run()
|
|
|
|
|
// c.Cli().Run("deploy", "to", "homelab")
|
2026-03-20 13:30:22 +00:00
|
|
|
func (cl *Cli) Run(args ...string) Result {
|
2026-03-20 12:08:19 +00:00
|
|
|
if len(args) == 0 {
|
|
|
|
|
args = os.Args[1:]
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:15:57 +00:00
|
|
|
clean := FilterArgs(args)
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
|
2026-03-20 17:35:09 +00:00
|
|
|
if cl.core == nil || cl.core.commands == nil {
|
|
|
|
|
if cl.banner != nil {
|
|
|
|
|
cl.Print(cl.banner(cl))
|
|
|
|
|
}
|
|
|
|
|
return Result{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cl.core.commands.mu.RLock()
|
|
|
|
|
cmdCount := len(cl.core.commands.commands)
|
|
|
|
|
cl.core.commands.mu.RUnlock()
|
|
|
|
|
|
|
|
|
|
if cmdCount == 0 {
|
2026-03-20 12:08:19 +00:00
|
|
|
if cl.banner != nil {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print(cl.banner(cl))
|
2026-03-20 12:08:19 +00:00
|
|
|
}
|
2026-03-20 13:30:22 +00:00
|
|
|
return Result{}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// Resolve command path from args
|
|
|
|
|
var cmd *Command
|
|
|
|
|
var remaining []string
|
|
|
|
|
|
2026-03-20 17:35:09 +00:00
|
|
|
cl.core.commands.mu.RLock()
|
2026-03-20 12:08:19 +00:00
|
|
|
for i := len(clean); i > 0; i-- {
|
2026-03-20 12:23:05 +00:00
|
|
|
path := JoinPath(clean[:i]...)
|
2026-03-20 12:08:19 +00:00
|
|
|
if c, ok := cl.core.commands.commands[path]; ok {
|
|
|
|
|
cmd = c
|
|
|
|
|
remaining = clean[i:]
|
|
|
|
|
break
|
|
|
|
|
}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
2026-03-20 17:35:09 +00:00
|
|
|
cl.core.commands.mu.RUnlock()
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
if cmd == nil {
|
|
|
|
|
if cl.banner != nil {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print(cl.banner(cl))
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
2026-03-20 12:08:19 +00:00
|
|
|
cl.PrintHelp()
|
2026-03-20 13:30:22 +00:00
|
|
|
return Result{}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
2026-03-20 12:08:19 +00:00
|
|
|
|
2026-03-20 12:17:30 +00:00
|
|
|
// Build options from remaining args
|
2026-03-24 19:17:12 +00:00
|
|
|
opts := NewOptions()
|
2026-03-20 12:08:19 +00:00
|
|
|
for _, arg := range remaining {
|
2026-03-20 12:15:57 +00:00
|
|
|
key, val, valid := ParseFlag(arg)
|
|
|
|
|
if valid {
|
2026-03-20 18:36:30 +00:00
|
|
|
if Contains(arg, "=") {
|
2026-03-24 19:17:12 +00:00
|
|
|
opts.Set(key, val)
|
2026-03-20 12:08:19 +00:00
|
|
|
} else {
|
2026-03-24 19:17:12 +00:00
|
|
|
opts.Set(key, true)
|
2026-03-20 12:08:19 +00:00
|
|
|
}
|
2026-03-20 12:24:39 +00:00
|
|
|
} else if !IsFlag(arg) {
|
2026-03-24 19:17:12 +00:00
|
|
|
opts.Set("_arg", arg)
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 18:48:02 +00:00
|
|
|
if cmd.Action != nil {
|
|
|
|
|
return cmd.Run(opts)
|
|
|
|
|
}
|
|
|
|
|
if cmd.Lifecycle != nil {
|
|
|
|
|
return cmd.Start(opts)
|
|
|
|
|
}
|
|
|
|
|
return Result{E("core.Cli.Run", Concat("command \"", cmd.Path, "\" is not executable"), nil), false}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// PrintHelp prints available commands.
|
|
|
|
|
//
|
|
|
|
|
// c.Cli().PrintHelp()
|
|
|
|
|
func (cl *Cli) PrintHelp() {
|
|
|
|
|
if cl.core == nil || cl.core.commands == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
name := ""
|
|
|
|
|
if cl.core.app != nil {
|
|
|
|
|
name = cl.core.app.Name
|
|
|
|
|
}
|
|
|
|
|
if name != "" {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print("%s commands:", name)
|
2026-03-20 12:08:19 +00:00
|
|
|
} else {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print("Commands:")
|
2026-03-20 12:08:19 +00:00
|
|
|
}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
cl.core.commands.mu.RLock()
|
|
|
|
|
defer cl.core.commands.mu.RUnlock()
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
for path, cmd := range cl.core.commands.commands {
|
2026-03-20 18:36:30 +00:00
|
|
|
if cmd.Hidden || (cmd.Action == nil && cmd.Lifecycle == nil) {
|
2026-03-20 12:08:19 +00:00
|
|
|
continue
|
|
|
|
|
}
|
2026-03-20 17:20:08 +00:00
|
|
|
tr := cl.core.I18n().Translate(cmd.I18nKey())
|
|
|
|
|
desc, _ := tr.Value.(string)
|
|
|
|
|
if desc == "" || desc == cmd.I18nKey() {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print(" %s", path)
|
2026-03-20 12:08:19 +00:00
|
|
|
} else {
|
2026-03-20 12:17:30 +00:00
|
|
|
cl.Print(" %-30s %s", path, desc)
|
2026-03-20 12:08:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// SetBanner sets the banner function.
|
|
|
|
|
//
|
|
|
|
|
// c.Cli().SetBanner(func(_ *core.Cli) string { return "My App v1.0" })
|
|
|
|
|
func (cl *Cli) SetBanner(fn func(*Cli) string) {
|
|
|
|
|
cl.banner = fn
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-20 12:08:19 +00:00
|
|
|
// Banner returns the banner string.
|
|
|
|
|
func (cl *Cli) Banner() string {
|
|
|
|
|
if cl.banner != nil {
|
|
|
|
|
return cl.banner(cl)
|
|
|
|
|
}
|
|
|
|
|
if cl.core != nil && cl.core.app != nil && cl.core.app.Name != "" {
|
|
|
|
|
return cl.core.app.Name
|
|
|
|
|
}
|
|
|
|
|
return ""
|
feat: restructure Core as unified struct with DTO pattern
Complete architectural overhaul of pkg/core:
- All subsystem types renamed to idiomatic Go (no stutter)
- Core struct: App, Embed, Fs, Config, ErrPan, ErrLog, Cli, Service, Lock, Ipc, I18n
- Exports consolidated in core.go, contracts/options in contract.go
- Service() unified get/register: c.Service(), c.Service("name"), c.Service("name", svc)
- Lock() named mutex map: c.Lock("srv"), c.Lock("ipc")
- Error system: Err/ErrLog/ErrPan + Log/LogErr/LogPan (shared ErrSink interface)
- CoreCommand with optional description (i18n resolves from command path)
- Tests moved to tests/ directory (black-box package core_test)
- Removed: ServiceFor/MustServiceFor, global instance, Display/Workspace/Crypt interfaces
- New files: app.go, fs.go, ipc.go, lock.go, i18n.go, task.go, runtime.go, contract.go
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-18 09:12:29 +00:00
|
|
|
}
|