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

     1  package who
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/henvic/wedeploycli/command/internal/we"
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  // WhoCmd get the current user
    12  var WhoCmd = &cobra.Command{
    13  	Use:   "who",
    14  	Short: "Get who is using Liferay Cloud",
    15  	Args:  cobra.NoArgs,
    16  	RunE:  whoRun,
    17  }
    18  
    19  func whoRun(cmd *cobra.Command, args []string) error {
    20  	var wectx = we.Context()
    21  	if wectx.Username() != "" {
    22  		fmt.Printf("%s in %s (%s)\n",
    23  			wectx.Username(),
    24  			wectx.Remote(),
    25  			wectx.InfrastructureDomain())
    26  		return nil
    27  	}
    28  
    29  	return errors.New("user is not available")
    30  }
    31  
    32  func init() {
    33  	WhoCmd.Hidden = true
    34  }