Set module to git.abrell.se/victor/mydev so it installs from the private Gitea host, and add an MIT LICENSE. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.abrell.se/victor/mydev/internal/config"
|
|
"git.abrell.se/victor/mydev/internal/run"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// devtool runs `rundev.sh ./bin/console mystore:devtool:<task> <args...>` from
|
|
// inside the legacy repo (mirrors the shell `myl table/snapshot/userfiles`).
|
|
func devtool(task string, args ...string) {
|
|
cfg, err := config.Load()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
rundev, err := cfg.LegacyRunDev()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
full := append([]string{"./bin/console", "mystore:devtool:" + task}, args...)
|
|
// cwd = legacy repo so ./bin/console resolves.
|
|
if err := run.Stream(cfg.LegacyDir, rundev, full...); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
var dataCmd = &cobra.Command{
|
|
Use: "data",
|
|
Short: "Fetch prod data via legacy devtool (rundev.sh)",
|
|
}
|
|
|
|
var dataTableCmd = &cobra.Command{
|
|
Use: "table [args...]",
|
|
Short: "Get a table (mystore:devtool:gettable)",
|
|
DisableFlagParsing: true,
|
|
Run: func(cmd *cobra.Command, args []string) { devtool("gettable", args...) },
|
|
}
|
|
|
|
var dataSnapshotCmd = &cobra.Command{
|
|
Use: "snapshot [args...]",
|
|
Short: "Get a snapshot (mystore:devtool:getsnapshot)",
|
|
DisableFlagParsing: true,
|
|
Run: func(cmd *cobra.Command, args []string) { devtool("getsnapshot", args...) },
|
|
}
|
|
|
|
var dataUserfilesCmd = &cobra.Command{
|
|
Use: "userfiles [args...]",
|
|
Short: "Get user files (mystore:devtool:getuserfiles)",
|
|
DisableFlagParsing: true,
|
|
Run: func(cmd *cobra.Command, args []string) { devtool("getuserfiles", args...) },
|
|
}
|
|
|
|
func init() {
|
|
dataCmd.AddCommand(dataTableCmd, dataSnapshotCmd, dataUserfilesCmd)
|
|
rootCmd.AddCommand(dataCmd)
|
|
}
|