github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/env-var/show/show.go (about)

     1  package show
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/henvic/wedeploycli/cmdflagsfromhost"
     7  	"github.com/henvic/wedeploycli/command/env-var/internal/commands"
     8  	"github.com/henvic/wedeploycli/command/internal/we"
     9  	"github.com/henvic/wedeploycli/services"
    10  	"github.com/spf13/cobra"
    11  )
    12  
    13  // Cmd for showing
    14  var Cmd = &cobra.Command{
    15  	Use:     "show",
    16  	Aliases: []string{"list"},
    17  	Short:   "Show your environment variable values for a given service",
    18  	Example: `  lcp env-var show
    19    lcp env-var show key`,
    20  	PreRunE: preRun,
    21  	RunE:    run,
    22  }
    23  
    24  var setupHost = cmdflagsfromhost.SetupHost{
    25  	Pattern: cmdflagsfromhost.FullHostPattern,
    26  
    27  	Requires: cmdflagsfromhost.Requires{
    28  		Auth:    true,
    29  		Project: true,
    30  		Service: true,
    31  	},
    32  
    33  	PromptMissingService: true,
    34  }
    35  
    36  func init() {
    37  	setupHost.Init(Cmd)
    38  }
    39  
    40  func preRun(cmd *cobra.Command, args []string) error {
    41  	return setupHost.Process(context.Background(), we.Context())
    42  }
    43  
    44  func run(cmd *cobra.Command, args []string) error {
    45  	var c = commands.Command{
    46  		SetupHost:      setupHost,
    47  		ServicesClient: services.New(we.Context()),
    48  	}
    49  
    50  	return c.Show(context.Background(), args...)
    51  }