github.com/palantir/godel-dep-plugin@v1.1.1-0.20201218041358-274eaa9b1310/cmd/dep.go (about)

     1  // Copyright (c) 2018 Palantir Technologies Inc. All rights reserved.
     2  // Use of this source code is governed by the Apache License, Version 2.0
     3  // that can be found in the LICENSE file.
     4  
     5  package cmd
     6  
     7  import (
     8  	"github.com/spf13/cobra"
     9  
    10  	"github.com/palantir/godel-dep-plugin/depplugin"
    11  )
    12  
    13  var depCmd = &cobra.Command{
    14  	Use:   "dep [flags] [args]",
    15  	Short: "Runs dep ensure for the project",
    16  	Long: `Executes "dep ensure" using the bundled version of dep with the provided flags and arguments. The "--" separator must 
    17  be used before specifying any flags for the "dep" program. For example, "./godelw dep -- -v" executes "dep ensure -v".`,
    18  	RunE: func(cmd *cobra.Command, args []string) error {
    19  		if verifyFlagVal {
    20  			return depplugin.Verify()
    21  		}
    22  		return depplugin.Run(append([]string{"ensure"}, args...), cmd.OutOrStdout())
    23  	},
    24  }
    25  
    26  func init() {
    27  	depCmd.Flags().BoolVar(&verifyFlagVal, "verify", false, "If --apply=false, runs `dep check`, otherwise runs `dep ensure`")
    28  	rootCmd.AddCommand(depCmd)
    29  }