first commit
This commit is contained in:
@@ -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
@@ -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
@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user