github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/commands/logout.go (about)

     1  package commands
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/commandregistry"
     5  	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
     6  	"code.cloudfoundry.org/cli/cf/flags"
     7  	. "code.cloudfoundry.org/cli/cf/i18n"
     8  	"code.cloudfoundry.org/cli/cf/requirements"
     9  	"code.cloudfoundry.org/cli/cf/terminal"
    10  )
    11  
    12  type Logout struct {
    13  	ui     terminal.UI
    14  	config coreconfig.ReadWriter
    15  }
    16  
    17  func init() {
    18  	commandregistry.Register(&Logout{})
    19  }
    20  
    21  func (cmd *Logout) MetaData() commandregistry.CommandMetadata {
    22  	return commandregistry.CommandMetadata{
    23  		Name:        "logout",
    24  		ShortName:   "lo",
    25  		Description: T("Log user out"),
    26  		Usage: []string{
    27  			T("CF_NAME logout"),
    28  		},
    29  	}
    30  }
    31  
    32  func (cmd *Logout) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
    33  	reqs := []requirements.Requirement{}
    34  	return reqs, nil
    35  }
    36  
    37  func (cmd *Logout) SetDependency(deps commandregistry.Dependency, _ bool) commandregistry.Command {
    38  	cmd.ui = deps.UI
    39  	cmd.config = deps.Config
    40  	return cmd
    41  }
    42  
    43  func (cmd *Logout) Execute(c flags.FlagContext) error {
    44  	cmd.ui.Say(T("Logging out..."))
    45  	cmd.config.ClearSession()
    46  	cmd.ui.Ok()
    47  	return nil
    48  }