Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add disable-pop-up flag + add logout command (#97)
- Loading branch information
Showing
3 changed files
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func NewLogoutCommand(c *LoginClient) (CommandOut, error) { | ||
return CommandOut{Command: &cli.Command{ | ||
Name: "logout", | ||
Usage: "Logout current user", | ||
Aliases: []string{"lo"}, | ||
Flags: []cli.Flag{ | ||
domainFlag, | ||
disablePopUpFlag, | ||
}, | ||
Action: func(ctx *cli.Context) error { | ||
logoutURL := fmt.Sprintf("https://%s/v2/logout", ctx.String("domain")) | ||
fmt.Printf("Logout via this url: %s\n", logoutURL) | ||
if !ctx.Bool("disable-pop-up") { | ||
if err := c.loginService.OpenBrowser(logoutURL); err != nil { | ||
return fmt.Errorf("Unable to open browser, please open url manually.") | ||
} | ||
} | ||
return nil | ||
}, | ||
}}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters