first commit

This commit is contained in:
2026-05-15 23:36:12 +08:00
parent 62fe8ddf4a
commit 52d6dde4aa
10 changed files with 286 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
package bundle
import (
"fmt"
"os"
"strings"
"cliprepo/internal/config"
"github.com/atotto/clipboard"
)
const maxFileSize = 1 * 1024 * 1024 // 1MB
func Build(key string) (string, error) {
cfg, err := config.Load()
if err != nil {
return "", err
}
files, ok := cfg.Bundles[key]
if !ok {
return "", fmt.Errorf("bundle not found: %s", key)
}
var builder strings.Builder
for _, file := range files {
info, err := os.Stat(file)
if err != nil {
continue
}
if info.Size() > maxFileSize {
continue
}
data, err := os.ReadFile(file)
if err != nil {
continue
}
builder.WriteString(fmt.Sprintf("===== %s =====\n", file))
builder.Write(data)
builder.WriteString("\n\n")
}
return builder.String(), nil
}
func Copy(content string) error {
return clipboard.WriteAll(content)
}