summaryrefslogtreecommitdiff
path: root/internal/cmd/list.go
blob: 90d0eb82780ff07d42b95b0c76d72d1ec4f31e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cmd

import (
	"os"

	"github.com/spf13/cobra"
	"codeberg.org/snonux/gitsyncer/internal/cli"
)

var listCmd = &cobra.Command{
	Use:   "list",
	Short: "List organizations and repositories",
	Long:  `Display configured organizations and repositories from the configuration file.`,
}

var listOrgsCmd = &cobra.Command{
	Use:   "orgs",
	Short: "List configured organizations",
	Example: `  # List all configured organizations
  gitsyncer list orgs`,
	Run: func(cmd *cobra.Command, args []string) {
		os.Exit(cli.HandleListOrgs(cfg))
	},
}

var listReposCmd = &cobra.Command{
	Use:   "repos",
	Short: "List configured repositories",
	Example: `  # List all configured repositories
  gitsyncer list repos`,
	Run: func(cmd *cobra.Command, args []string) {
		os.Exit(cli.HandleListRepos(cfg))
	},
}

func init() {
	rootCmd.AddCommand(listCmd)
	listCmd.AddCommand(listOrgsCmd)
	listCmd.AddCommand(listReposCmd)
}