mirror.go

 1package cmd
 2
 3import (
 4	"github.com/spf13/cobra"
 5)
 6
 7func mirrorCommand() *cobra.Command {
 8	cmd := &cobra.Command{
 9		Use:               "is-mirror REPOSITORY",
10		Short:             "Whether a repository is a mirror",
11		Args:              cobra.ExactArgs(1),
12		PersistentPreRunE: checkIfReadable,
13		RunE: func(cmd *cobra.Command, args []string) error {
14			ctx := cmd.Context()
15			be, _ := fromContext(cmd)
16			rn := args[0]
17			rr, err := be.Repository(ctx, rn)
18			if err != nil {
19				return err
20			}
21
22			isMirror := rr.IsMirror()
23			cmd.Println(isMirror)
24			return nil
25		},
26	}
27
28	return cmd
29}