afbe270181
Two changes: 1. structured-add-commands: The implicit note shorthand (kb "text") caused accidental note creation from mistyped commands. Replaced with explicit kb addnote <text> command. Root command reverts to standard Cobra behaviour. Updated examples, tests, SKILL.md, and specs. 2. split-readme-developer-docs: Moved build-from-source instructions, release process, API reference, and ROCm migration notes from README.md into a new DEVELOPER.md. README now links to DEVELOPER.md for dev workflows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/kb-search/kb/internal/api"
|
|
"github.com/kb-search/kb/internal/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Version is set at build time via -ldflags.
|
|
var Version = "dev"
|
|
|
|
// MinEngineVersion is set at build time via -ldflags.
|
|
var MinEngineVersion = "dev"
|
|
|
|
var (
|
|
flagEngine string
|
|
flagFormat string
|
|
flagAPIKey string
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "kb [command]",
|
|
Short: "kb-search CLI client",
|
|
Long: "A CLI client for the kb-search v2 engine API.\nRun 'kb examples' for common usage patterns.",
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
if err := config.Load(); err != nil {
|
|
return err
|
|
}
|
|
config.ApplyFlags(flagEngine, flagFormat, flagAPIKey)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
api.SetVersionInfo(Version, MinEngineVersion)
|
|
rootCmd.Version = Version
|
|
rootCmd.PersistentFlags().StringVar(&flagEngine, "engine", "", "engine API URL")
|
|
rootCmd.PersistentFlags().StringVar(&flagFormat, "format", "", "output format (human|json)")
|
|
rootCmd.PersistentFlags().StringVar(&flagAPIKey, "api-key", "", "API key for authentication")
|
|
}
|
|
|
|
// Execute runs the root command.
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|