9aab79d49b
- Remove v1 Python CLI (src/kb_search/, tests/, root pyproject.toml, uv.lock, .venv) - Add Go client with cross-platform build (client/) - Add FastAPI engine with NVIDIA and multi-stage ROCm Dockerfiles (engine/) - Add VERSION files for client and engine, wired into builds - Add release.sh for automated build, tag, release, and Docker push - Update README with build/release docs and ROCm migration note - Clean up .gitignore for v2 project structure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/kb-search/kb/internal/api"
|
|
"github.com/kb-search/kb/internal/output"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var removeCmd = &cobra.Command{
|
|
Use: "remove <id>",
|
|
Short: "Remove a document from the knowledge base",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: runRemove,
|
|
}
|
|
|
|
func init() {
|
|
removeCmd.Flags().BoolP("yes", "y", false, "skip confirmation prompt")
|
|
rootCmd.AddCommand(removeCmd)
|
|
}
|
|
|
|
func runRemove(cmd *cobra.Command, args []string) error {
|
|
yes, _ := cmd.Flags().GetBool("yes")
|
|
|
|
if !yes {
|
|
fmt.Printf("Remove document %s? [y/N] ", args[0])
|
|
reader := bufio.NewReader(os.Stdin)
|
|
answer, _ := reader.ReadString('\n')
|
|
answer = strings.TrimSpace(strings.ToLower(answer))
|
|
if answer != "y" && answer != "yes" {
|
|
fmt.Println("Cancelled.")
|
|
return nil
|
|
}
|
|
}
|
|
|
|
client := api.NewClient()
|
|
resp, err := client.Delete("/api/v1/documents/" + args[0])
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
if err := api.CheckError(resp); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if output.IsJSON() {
|
|
var raw interface{}
|
|
if err := api.DecodeJSON(resp, &raw); err != nil {
|
|
// Some DELETE endpoints return no body
|
|
output.PrintJSON(map[string]string{"status": "removed", "id": args[0]})
|
|
return nil
|
|
}
|
|
output.PrintJSON(raw)
|
|
} else {
|
|
fmt.Printf("Removed: %s\n", args[0])
|
|
}
|
|
return nil
|
|
}
|