MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / runLogout

Function runLogout

cmd/login.go:613–641  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

611}
612
613func runLogout() error {
614 envToken := os.Getenv("TNR_API_TOKEN")
615
616 configDir, err := utils.ThunderDir()
617 if err != nil {
618 return fmt.Errorf("failed to resolve thunder directory: %w", err)
619 }
620
621 configPath := filepath.Join(configDir, "cli_config.json")
622 configExists := true
623 if _, err := os.Stat(configPath); os.IsNotExist(err) {
624 configExists = false
625 }
626
627 if !configExists && envToken == "" {
628 PrintWarningSimple("You are not logged in.")
629 return nil
630 } else if envToken != "" {
631 PrintWarningSimple("You are authenticated via TNR_API_TOKEN environment variable.")
632 return nil
633 }
634
635 if err := os.Remove(configPath); err != nil {
636 return fmt.Errorf("failed to remove config file: %w", err)
637 }
638
639 PrintSuccessSimple("Successfully logged out from Thunder Compute!")
640 return nil
641}

Callers 1

login.goFile · 0.85

Calls 4

ThunderDirFunction · 0.92
PrintWarningSimpleFunction · 0.85
PrintSuccessSimpleFunction · 0.85
StatMethod · 0.65

Tested by

no test coverage detected