From 1cb83c13b0a8d72cf82936452964ba8a8b751da7 Mon Sep 17 00:00:00 2001 From: Anurag Yadav Date: Sun, 24 May 2026 01:24:17 +0530 Subject: [PATCH] feat: allow grepturbo as shorthand for grepturbo search Patterns that don't match a known subcommand name are automatically routed to the search command, so both `grepturbo "foo"` and `grepturbo foo` work. --- cmd/grepturbo/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/grepturbo/main.go b/cmd/grepturbo/main.go index 3a5ef81..8e36281 100644 --- a/cmd/grepturbo/main.go +++ b/cmd/grepturbo/main.go @@ -14,6 +14,20 @@ import ( const defaultIndexDir = ".grepturbo" func main() { + // If the first arg isn't a known subcommand or flag, treat it as a search pattern + // so `grepturbo ` works alongside `grepturbo search `. + knownSubcmds := map[string]bool{"build": true, "search": true, "init": true, "help": true, "completion": true} + if len(os.Args) > 1 { + first := os.Args[1] + if first != "" && first[0] != '-' && !knownSubcmds[first] { + // Inject "search" before the pattern + newArgs := make([]string, 0, len(os.Args)+1) + newArgs = append(newArgs, os.Args[0], "search") + newArgs = append(newArgs, os.Args[1:]...) + os.Args = newArgs + } + } + rootCmd := &cobra.Command{ Use: "grepturbo", Short: "Index-accelerated regex search",