github.com/zaquestion/lab@v0.25.1/cmd/project_browse.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  	lab "github.com/zaquestion/lab/internal/gitlab"
     6  )
     7  
     8  var projectBrowseCmd = &cobra.Command{
     9  	Use:              "browse [remote]",
    10  	Aliases:          []string{"b"},
    11  	Short:            "View project in a browser",
    12  	Example:          "lab project browse origin",
    13  	PersistentPreRun: labPersistentPreRun,
    14  	Run: func(cmd *cobra.Command, args []string) {
    15  		rn, _, err := parseArgsRemoteAndID(args)
    16  		if err != nil {
    17  			log.Fatal(err)
    18  		}
    19  
    20  		p, err := lab.FindProject(rn)
    21  		if err != nil {
    22  			log.Fatal(err)
    23  		}
    24  
    25  		err = browse(p.WebURL)
    26  		if err != nil {
    27  			log.Fatal(err)
    28  		}
    29  	},
    30  }
    31  
    32  func init() {
    33  	projectCmd.AddCommand(projectBrowseCmd)
    34  }