bluesky viewer in the terminal
at main 1.3 kB view raw
1package main 2 3import ( 4 "context" 5 "fmt" 6 7 "github.com/stormlightlabs/skypanel/cli/internal/registry" 8 "github.com/stormlightlabs/skypanel/cli/internal/setup" 9 "github.com/stormlightlabs/skypanel/cli/internal/store" 10 "github.com/stormlightlabs/skypanel/cli/internal/ui" 11 "github.com/urfave/cli/v3" 12) 13 14func StatusCommand() *cli.Command { 15 return &cli.Command{ 16 Name: "status", 17 Usage: "Show current session status", 18 Action: StatusAction, 19 } 20} 21 22func StatusAction(ctx context.Context, cmd *cli.Command) error { 23 if err := setup.EnsurePersistenceReady(ctx); err != nil { 24 return fmt.Errorf("persistence layer not ready: %w", err) 25 } 26 27 reg := registry.Get() 28 29 sessionRepo, err := reg.GetSessionRepo() 30 if err != nil { 31 return fmt.Errorf("failed to get session repository: %w", err) 32 } 33 34 if !sessionRepo.HasValidSession(ctx) { 35 ui.Infoln("Not authenticated. Run 'skycli login' to authenticate.") 36 return nil 37 } 38 39 session, err := sessionRepo.List(ctx) 40 if err != nil { 41 logger.Error("Failed to get session", "error", err) 42 return err 43 } 44 45 if len(session) > 0 { 46 if s, ok := session[0].(*store.SessionModel); ok { 47 ui.Titleln("Session Status") 48 ui.Infoln("Handle: %s", s.Handle) 49 ui.Infoln("Service: %s", s.ServiceURL) 50 ui.Successln("Authenticated") 51 } 52 } 53 54 return nil 55}