2026-08-22 21:41:05 +02:00
|
|
|
// Package cli wires the agent-lib command tree: vendor (curator side),
|
|
|
|
|
// sync/status (client side) and version.
|
|
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
2026-08-22 21:52:30 +02:00
|
|
|
"os"
|
2026-08-22 21:41:05 +02:00
|
|
|
"runtime"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
|
|
"github.com/m3tam3re/agent-lib/internal/version"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func NewRootCmd() *cobra.Command {
|
|
|
|
|
root := &cobra.Command{
|
|
|
|
|
Use: "agent-lib",
|
|
|
|
|
Short: "Curated agent content: vendor external sources, sync to OpenCode",
|
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
SilenceErrors: true,
|
|
|
|
|
}
|
|
|
|
|
root.AddCommand(newVersionCmd())
|
2026-08-22 21:52:30 +02:00
|
|
|
root.AddCommand(newVendorCmd())
|
2026-08-22 21:54:32 +02:00
|
|
|
root.AddCommand(newValidateCmd())
|
2026-08-23 10:31:00 +02:00
|
|
|
root.AddCommand(newSyncCmd())
|
2026-08-22 21:41:05 +02:00
|
|
|
return root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newVersionCmd() *cobra.Command {
|
|
|
|
|
return &cobra.Command{
|
|
|
|
|
Use: "version",
|
|
|
|
|
Short: "Print the agent-lib version",
|
|
|
|
|
Args: cobra.NoArgs,
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
return printVersion(cmd.OutOrStdout())
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func printVersion(w io.Writer) error {
|
|
|
|
|
_, err := fmt.Fprintf(w, "agent-lib %s (%s/%s)\n", version.Version, runtime.GOOS, runtime.GOARCH)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Execute() error {
|
2026-08-22 21:52:30 +02:00
|
|
|
if err := NewRootCmd().Execute(); err != nil {
|
|
|
|
|
fmt.Fprintln(os.Stderr, "error:", err)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
2026-08-22 21:41:05 +02:00
|
|
|
}
|