Basic provisioning api

Includes: login, logout, and ping.
This commit is contained in:
Gary Kramlich
2022-02-21 06:49:44 -06:00
parent a51b1074ba
commit d883befee5
10 changed files with 429 additions and 6 deletions

View File

@@ -48,6 +48,7 @@ type commands struct {
Help helpCmd `kong:"cmd,help='Displays this message.'"`
Login loginCmd `kong:"cmd,help='Log in to Discord.'"`
Logout logoutCmd `kong:"cmd,help='Log out of Discord.'"`
Version versionCmd `kong:"cmd,help='Displays the version of the bridge.'"`
}
@@ -134,3 +135,24 @@ func (l *loginCmd) Run(g *globals) error {
return nil
}
type logoutCmd struct{}
func (l *logoutCmd) Run(g *globals) error {
if !g.user.LoggedIn() {
fmt.Fprintln(g.context.Stdout, "You are not logged in")
return fmt.Errorf("user is not logged in")
}
err := g.user.DeleteSession()
if err != nil {
fmt.Fprintln(g.context.Stdout, "Failed to log out")
return err
}
fmt.Fprintln(g.context.Stdout, "Successfully logged out")
return nil
}