Borg/cmd/collect.go
google-labs-jules[bot] 21f9a9ca74 feat: Implement core data collection and Trix cube functionality
This commit introduces the core functionality of the Borg Data Collector.

- Adds the `collect` command to clone a single Git repository and store it in a Trix cube.
- Adds the `collect all` command to clone all public repositories from a GitHub user or organization.
- Implements the Trix cube as a `tar` archive.
- Adds the `ingest` command to add files to a Trix cube.
- Adds the `cat` command to extract files from a Trix cube.
- Integrates Borg-themed status messages for a more engaging user experience.
2025-10-31 05:02:29 +00:00

45 lines
1 KiB
Go

package cmd
import (
"fmt"
"borg-data-collector/pkg/trix"
"github.com/spf13/cobra"
)
// collectCmd represents the collect command
var collectCmd = &cobra.Command{
Use: "collect [repository-url]",
Short: "Collect a single repository",
Long: `Collect a single repository and store it in a Trix cube.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
fmt.Println("Please provide a repository URL")
return
}
repoURL := args[0]
clonePath, _ := cmd.Flags().GetString("path")
outputFile, _ := cmd.Flags().GetString("output")
cube, err := trix.NewCube(outputFile)
if err != nil {
fmt.Println(err)
return
}
defer cube.Close()
err = addRepoToCube(repoURL, cube, clonePath)
if err != nil {
fmt.Println(err)
return
}
},
}
func init() {
rootCmd.AddCommand(collectCmd)
collectCmd.PersistentFlags().String("path", "/tmp/borg-clone", "Path to clone the repository")
collectCmd.PersistentFlags().String("output", "borg.cube", "Output file for the Trix cube")
}