@@ -126,17 +126,11 @@ Examples:
126126 return fmt .Errorf ("API key validation failed: %w" , err )
127127 }
128128
129- // Store the API key securely
130- if err := config .StoreAPIKey (apiKey ); err != nil {
131- return fmt .Errorf ("failed to store API key : %w" , err )
129+ // Store the credentials ( API key + project ID) together securely
130+ if err := config .StoreCredentials (apiKey , creds . projectID ); err != nil {
131+ return fmt .Errorf ("failed to store credentials : %w" , err )
132132 }
133- fmt .Fprintln (cmd .OutOrStdout (), "Successfully logged in and stored API key" )
134-
135- // Store project ID in config if provided
136- if err := storeProjectID (creds .projectID ); err != nil {
137- return fmt .Errorf ("failed to store project ID: %w" , err )
138- }
139- fmt .Fprintf (cmd .OutOrStdout (), "Set default project ID to: %s\n " , creds .projectID )
133+ fmt .Fprintf (cmd .OutOrStdout (), "Successfully logged in (project: %s)\n " , creds .projectID )
140134
141135 // Show helpful next steps
142136 fmt .Fprint (cmd .OutOrStdout (), nextStepsMessage )
@@ -161,8 +155,8 @@ func buildLogoutCmd() *cobra.Command {
161155 RunE : func (cmd * cobra.Command , args []string ) error {
162156 cmd .SilenceUsage = true
163157
164- if err := config .RemoveAPIKey (); err != nil {
165- return fmt .Errorf ("failed to remove API key : %w" , err )
158+ if err := config .RemoveCredentials (); err != nil {
159+ return fmt .Errorf ("failed to remove credentials : %w" , err )
166160 }
167161
168162 fmt .Fprintln (cmd .OutOrStdout (), "Successfully logged out and removed stored credentials" )
@@ -174,17 +168,19 @@ func buildLogoutCmd() *cobra.Command {
174168func buildStatusCmd () * cobra.Command {
175169 return & cobra.Command {
176170 Use : "status" ,
177- Short : "Show current auth information " ,
178- Long : `Show information about the currently authenticated token.` ,
171+ Short : "Show current authentication status and project ID " ,
172+ Long : "Displays whether you are logged in and shows your currently configured project ID." ,
179173 RunE : func (cmd * cobra.Command , args []string ) error {
180174 cmd .SilenceUsage = true
181175
182- if _ , err := config .GetAPIKey (); err != nil {
176+ _ , projectID , err := config .GetCredentials ()
177+ if err != nil {
183178 return err
184179 }
185180
186181 // TODO: Make API call to get token information
187182 fmt .Fprintln (cmd .OutOrStdout (), "Logged in (API key stored)" )
183+ fmt .Fprintf (cmd .OutOrStdout (), "Project ID: %s\n " , projectID )
188184
189185 return nil
190186 },
@@ -256,13 +252,3 @@ func promptForCredentials(consoleURL string, creds credentials) (credentials, er
256252
257253 return creds , nil
258254}
259-
260- // storeProjectID stores the project ID in the configuration file
261- func storeProjectID (projectID string ) error {
262- cfg , err := config .Load ()
263- if err != nil {
264- return fmt .Errorf ("failed to load config: %w" , err )
265- }
266-
267- return cfg .Set ("project_id" , projectID )
268- }
0 commit comments