github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_logout.go (about)

     1  // Copyright (C) 2015 Scaleway. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE.md file.
     4  
     5  package cli
     6  
     7  import "github.com/scaleway/scaleway-cli/pkg/commands"
     8  
     9  var cmdLogout = &Command{
    10  	Exec:        runLogout,
    11  	UsageLine:   "logout [OPTIONS]",
    12  	Description: "Log out from the Scaleway API",
    13  	Help:        "Log out from the Scaleway API.",
    14  }
    15  
    16  func init() {
    17  	cmdLogout.Flag.BoolVar(&logoutHelp, []string{"h", "-help"}, false, "Print usage")
    18  }
    19  
    20  // FLags
    21  var logoutHelp bool // -h, --help flag
    22  
    23  func runLogout(cmd *Command, rawArgs []string) error {
    24  	if logoutHelp {
    25  		return cmd.PrintUsage()
    26  	}
    27  	if len(rawArgs) != 0 {
    28  		return cmd.PrintShortUsage()
    29  	}
    30  
    31  	args := commands.LogoutArgs{}
    32  	ctx := cmd.GetContext(rawArgs)
    33  	return commands.RunLogout(ctx, args)
    34  }