Replace passthrough() + stdlib flag.FlagSet anti-pattern with proper cobra integration. Every Run* function now takes a typed *Opts struct and returns error. Flags registered via cli.StringFlag/IntFlag/etc. Commands participate in Core lifecycle with full cobra flag parsing. - 6 command groups: gen, score, data, export, infra, mon - 25 commands converted, 0 passthrough() calls remain - Delete passthrough() helper from lem.go - Update export_test.go to use ExportOpts struct Co-Authored-By: Virgil <virgil@lethean.io>
66 lines
2.7 KiB
Go
66 lines
2.7 KiB
Go
package lemcmd
|
|
|
|
import (
|
|
"forge.lthn.ai/core/cli/pkg/cli"
|
|
"forge.lthn.ai/lthn/lem/pkg/lem"
|
|
)
|
|
|
|
func addMonCommands(root *cli.Command) {
|
|
monGroup := cli.NewGroup("mon", "Monitoring commands", "Training progress, pipeline status, inventory, coverage, and metrics.")
|
|
|
|
// status — training and generation progress from InfluxDB.
|
|
var statusCfg lem.StatusOpts
|
|
statusCmd := cli.NewCommand("status", "Show training and generation progress (InfluxDB)", "",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return lem.RunStatus(statusCfg)
|
|
},
|
|
)
|
|
cli.StringFlag(statusCmd, &statusCfg.Influx, "influx", "", "", "InfluxDB URL (default http://10.69.69.165:8181)")
|
|
cli.StringFlag(statusCmd, &statusCfg.InfluxDB, "influx-db", "", "", "InfluxDB database name (default training)")
|
|
cli.StringFlag(statusCmd, &statusCfg.DB, "db", "", "", "DuckDB database path (shows table counts)")
|
|
monGroup.AddCommand(statusCmd)
|
|
|
|
// expand-status — expansion pipeline status from DuckDB.
|
|
var expandStatusCfg lem.ExpandStatusOpts
|
|
expandStatusCmd := cli.NewCommand("expand-status", "Show expansion pipeline status (DuckDB)", "",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return lem.RunExpandStatus(expandStatusCfg)
|
|
},
|
|
)
|
|
cli.StringFlag(expandStatusCmd, &expandStatusCfg.DB, "db", "", "", "DuckDB database path (defaults to LEM_DB env)")
|
|
monGroup.AddCommand(expandStatusCmd)
|
|
|
|
// inventory — DuckDB table inventory.
|
|
var inventoryCfg lem.InventoryOpts
|
|
inventoryCmd := cli.NewCommand("inventory", "Show DuckDB table inventory", "",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return lem.RunInventory(inventoryCfg)
|
|
},
|
|
)
|
|
cli.StringFlag(inventoryCmd, &inventoryCfg.DB, "db", "", "", "DuckDB database path (defaults to LEM_DB env)")
|
|
monGroup.AddCommand(inventoryCmd)
|
|
|
|
// coverage — seed coverage gap analysis.
|
|
var coverageCfg lem.CoverageOpts
|
|
coverageCmd := cli.NewCommand("coverage", "Analyse seed coverage gaps", "",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return lem.RunCoverage(coverageCfg)
|
|
},
|
|
)
|
|
cli.StringFlag(coverageCmd, &coverageCfg.DB, "db", "", "", "DuckDB database path (defaults to LEM_DB env)")
|
|
monGroup.AddCommand(coverageCmd)
|
|
|
|
// metrics — push DuckDB golden set stats to InfluxDB.
|
|
var metricsCfg lem.MetricsOpts
|
|
metricsCmd := cli.NewCommand("metrics", "Push DuckDB golden set stats to InfluxDB", "",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return lem.RunMetrics(metricsCfg)
|
|
},
|
|
)
|
|
cli.StringFlag(metricsCmd, &metricsCfg.DB, "db", "", "", "DuckDB database path (defaults to LEM_DB env)")
|
|
cli.StringFlag(metricsCmd, &metricsCfg.Influx, "influx", "", "", "InfluxDB URL")
|
|
cli.StringFlag(metricsCmd, &metricsCfg.InfluxDB, "influx-db", "", "", "InfluxDB database name")
|
|
monGroup.AddCommand(metricsCmd)
|
|
|
|
root.AddCommand(monGroup)
|
|
}
|