Add grep and server read/write/edit tools for agents
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"g.fc.run/ai/byre/internal/grep"
|
||||
)
|
||||
|
||||
func grepCmd(args []string) {
|
||||
fs := flag.NewFlagSet("grep", flag.ExitOnError)
|
||||
opts := grep.Options{}
|
||||
fs.StringVar(&opts.Glob, "glob", "", "search only files whose names match this glob")
|
||||
fs.BoolVar(&opts.IgnoreCase, "ignore-case", false, "match case-insensitively")
|
||||
fs.BoolVar(&opts.FilesOnly, "files-only", false, "list matching files, not lines")
|
||||
fs.Parse(args)
|
||||
if fs.NArg() != 2 {
|
||||
usage()
|
||||
}
|
||||
out, err := grep.Search(context.Background(), fs.Arg(0), "", fs.Arg(1), opts)
|
||||
if err != nil {
|
||||
fatal("grep failed", "err", err)
|
||||
}
|
||||
fmt.Print(out)
|
||||
}
|
||||
+3
-1
@@ -22,13 +22,15 @@ func main() {
|
||||
runCmd(os.Args[2:])
|
||||
case "signing":
|
||||
signingCmd(os.Args[2:])
|
||||
case "grep":
|
||||
grepCmd(os.Args[2:])
|
||||
default:
|
||||
usage()
|
||||
}
|
||||
}
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintln(os.Stderr, "usage: byre serve | byre install | byre check | byre run [--resume ID] | byre signing CHECKOUT")
|
||||
fmt.Fprintln(os.Stderr, "usage: byre serve | byre install | byre check | byre run [--resume ID] | byre signing CHECKOUT | byre grep [--glob GLOB] [--ignore-case] [--files-only] PATTERN PATH")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user