MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / NewApp

Function NewApp

internal/tui/app.go:88–119  ·  view source on GitHub ↗
(version string)

Source from the content-addressed store, hash-verified

86}
87
88func NewApp(version string) (*App, error) {
89 client, err := api.New()
90 if err != nil {
91 return nil, err
92 }
93
94 database, _ := db.New() // non-fatal
95
96 viewMode := ViewModeInitAuth
97 if client.IsInitialized() {
98 viewMode = ViewModePricing
99 }
100
101 // Start with sensible defaults; the real size arrives via WindowSizeMsg
102 // on the first frame and updates every view immediately.
103 app := &App{
104 version: version,
105 client: client,
106 db: database,
107 viewMode: viewMode,
108 authState: AuthStatePrompt,
109 pricingView: views.NewPricingView(0, 0),
110 historyView: views.NewHistoryView(0, 0),
111 settingsView: views.NewSettingsView(0, 0),
112 }
113
114 if viewMode == ViewModePricing {
115 app.loadMetadataIntoView()
116 }
117
118 return app, nil
119}
120
121func (a *App) loadMetadataIntoView() {
122 meta, err := api.LoadMetadataFromFile()

Callers 1

runTUIFunction · 0.92

Calls 7

loadMetadataIntoViewMethod · 0.95
NewFunction · 0.92
NewFunction · 0.92
NewPricingViewFunction · 0.92
NewHistoryViewFunction · 0.92
NewSettingsViewFunction · 0.92
IsInitializedMethod · 0.80

Tested by

no test coverage detected