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
+36
View File
@@ -0,0 +1,36 @@
package cmd
import (
"fmt"
"cliprepo/internal/bundle"
"github.com/spf13/cobra"
)
var bundleClipboard bool
var bundleCmd = &cobra.Command{
Use: "bundle [key]",
Short: "Bundle files by key from config",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
key := args[0]
result, err := bundle.Build(key)
if err != nil {
return err
}
if bundleClipboard {
return bundle.Copy(result)
}
fmt.Println(result)
return nil
},
}
func init() {
rootCmd.AddCommand(bundleCmd)
bundleCmd.Flags().BoolVar(&bundleClipboard, "clipboard", false, "Copy to clipboard")
}
+18
View File
@@ -0,0 +1,18 @@
package cmd
import (
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "cliprepo",
Short: "Extract repo structure and bundle code for LLMs",
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}
+40
View File
@@ -0,0 +1,40 @@
package cmd
import (
"fmt"
"cliprepo/internal/tree"
"github.com/spf13/cobra"
)
var treeOutput string
var treeClipboard bool
var treeCmd = &cobra.Command{
Use: "tree",
Short: "Print repo tree respecting .gitignore",
RunE: func(cmd *cobra.Command, args []string) error {
result, err := tree.Generate(".")
if err != nil {
return err
}
if treeClipboard {
return tree.Copy(result)
}
if treeOutput != "" {
return tree.Write(treeOutput, result)
}
fmt.Println(result)
return nil
},
}
func init() {
rootCmd.AddCommand(treeCmd)
treeCmd.Flags().StringVarP(&treeOutput, "output", "o", "", "Output file")
treeCmd.Flags().BoolVar(&treeClipboard, "clipboard", false, "Copy to clipboard")
}