clean dead codes
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/atotto/clipboard"
|
||||
)
|
||||
|
||||
func copyToClipboard(content string) error {
|
||||
return clipboard.WriteAll(content)
|
||||
}
|
||||
-11
@@ -29,7 +29,6 @@ var runCmd = &cobra.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
// 1. tree
|
||||
treeStr, err := tree.Generate(".")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -39,7 +38,6 @@ var runCmd = &cobra.Command{
|
||||
builder.WriteString(treeStr)
|
||||
builder.WriteString("\n\n")
|
||||
|
||||
// 2. resolver (GLOBAL FILE REGISTRY)
|
||||
r := resolver.New(".")
|
||||
|
||||
raw, ok := cfg.Preset[delineate]
|
||||
@@ -51,7 +49,6 @@ var runCmd = &cobra.Command{
|
||||
var files []string
|
||||
|
||||
for _, pattern := range patterns {
|
||||
// 统一交给 resolver 处理,无论是 "*", "cmd/*" 还是 "**/*.go"
|
||||
matches, err := r.ResolvePattern(pattern)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -59,17 +56,9 @@ var runCmd = &cobra.Command{
|
||||
files = append(files, matches...)
|
||||
}
|
||||
|
||||
// 3. dedup + stable order
|
||||
files = r.Unique(files)
|
||||
sort.Strings(files)
|
||||
|
||||
// 4. template
|
||||
template := cfg.Prompts.Preset
|
||||
if template == "" {
|
||||
template = "The following code is from file {{path}}:\n---\n{{content}}"
|
||||
}
|
||||
|
||||
// 5. render
|
||||
for _, file := range files {
|
||||
content, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func ExpandPaths(patterns []string) ([]string, error) {
|
||||
var result []string
|
||||
|
||||
for _, pattern := range patterns {
|
||||
matches, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, m := range matches {
|
||||
info, err := os.Stat(m)
|
||||
if err != nil || info.IsDir() {
|
||||
continue
|
||||
}
|
||||
result = append(result, m)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
// "strings"
|
||||
)
|
||||
|
||||
func ExpandGlob(patterns []string) ([]string, error) {
|
||||
var result []string
|
||||
|
||||
for _, pattern := range patterns {
|
||||
|
||||
if pattern == "*" {
|
||||
files, err := filepath.Glob("**") // fallback
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, files...)
|
||||
continue
|
||||
}
|
||||
|
||||
matches, err := filepath.Glob(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, m := range matches {
|
||||
info, err := os.Stat(m)
|
||||
if err != nil || info.IsDir() {
|
||||
continue
|
||||
}
|
||||
result = append(result, m)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func add(path string, seen map[string]struct{}, result *[]string) {
|
||||
if _, ok := seen[path]; ok {
|
||||
return
|
||||
}
|
||||
seen[path] = struct{}{}
|
||||
*result = append(*result, path)
|
||||
}
|
||||
Reference in New Issue
Block a user