Borg/cmd/all.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

61 lines
1.3 KiB
Go

package cmd
import (
"fmt"
"os"
"borg-data-collector/pkg/borg"
"borg-data-collector/pkg/github"
"borg-data-collector/pkg/trix"
"github.com/spf13/cobra"
)
// allCmd represents the all command
var allCmd = &cobra.Command{
Use: "all [user/org]",
Short: "Collect all public repositories from a user or organization",
Long: `Collect all public repositories from a user or organization and store them in a Trix cube.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(borg.GetRandomAssimilationMessage())
repos, err := github.GetPublicRepos(args[0])
if err != nil {
fmt.Println(err)
return
}
outputFile, _ := cmd.Flags().GetString("output")
cube, err := trix.NewCube(outputFile)
if err != nil {
fmt.Println(err)
return
}
defer cube.Close()
for _, repoURL := range repos {
fmt.Printf("Cloning %s...\n", repoURL)
tempPath, err := os.MkdirTemp("", "borg-clone-*")
if err != nil {
fmt.Println(err)
return
}
defer os.RemoveAll(tempPath)
err = addRepoToCube(repoURL, cube, tempPath)
if err != nil {
fmt.Printf("Error cloning %s: %s\n", repoURL, err)
continue
}
}
fmt.Println(borg.GetRandomCodeLongMessage())
},
}
func init() {
collectCmd.AddCommand(allCmd)
}