This commit introduces a new `collect github repos` command to the CLI. This command allows users to fetch all public repositories for a given user or organization. Key changes: - Added a new command file `cmd/collect_github_repos.go`. - Updated the documentation in `docs/index.md` to include the new command and the `collect github release` command.
28 lines
567 B
Go
28 lines
567 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Snider/Borg/pkg/github"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var collectGithubReposCmd = &cobra.Command{
|
|
Use: "repos [user-or-org]",
|
|
Short: "Collects all public repositories for a user or organization",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
repos, err := github.GetPublicRepos(cmd.Context(), args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, repo := range repos {
|
|
fmt.Println(repo)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
collectGithubCmd.AddCommand(collectGithubReposCmd)
|
|
}
|