github.com/gfleury/gobbs@v0.0.0-20200831213239-44ca2b94c1a1/repos/rp.go (about)

     1  package repos
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gfleury/gobbs/common"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  func init() {
    11  	ReposRoot.AddCommand(List)
    12  	ReposRoot.AddCommand(Create)
    13  }
    14  
    15  // ReposRoot cmd root for cobra
    16  var ReposRoot = &cobra.Command{
    17  	Use:     "repo",
    18  	Aliases: []string{"rp"},
    19  	Short:   "Interact with repositories",
    20  	Args:    cobra.MinimumNArgs(0),
    21  	RunE: func(cmd *cobra.Command, args []string) error {
    22  		if len(args) == 0 {
    23  			return List.RunE(cmd, args)
    24  		}
    25  		return fmt.Errorf("Commnand not found")
    26  	},
    27  }
    28  
    29  func mustHaveProject(stashInfo *common.StashInfo) error {
    30  	if *stashInfo.Project() == "" {
    31  		return fmt.Errorf("Unable to identify Project")
    32  	}
    33  	return nil
    34  }