Skip to content

Commit a0f86d7

Browse files
committed
feat: cleanup app creation outputs when passed
1 parent f0d20ad commit a0f86d7

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

cmd/app/link.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,37 @@ func LinkExistingApp(ctx context.Context, clients *shared.ClientFactory, app *ty
192192
return nil
193193
}
194194

195+
// LinkExistingAppQuiet links an existing app without verbose output. It resolves
196+
// the team and environment, validates the app, saves it, and prints only the app
197+
// summary. Used by `create --app` where the surrounding create output is enough.
198+
func LinkExistingAppQuiet(ctx context.Context, clients *shared.ClientFactory, app *types.App) error {
199+
linkedApp, auth, err := promptExistingApp(ctx, clients)
200+
if err != nil {
201+
return err
202+
}
203+
*app = linkedApp
204+
205+
appIDs := []string{app.AppID}
206+
_, err = clients.API().GetAppStatus(ctx, auth.Token, appIDs, app.TeamID)
207+
if err != nil {
208+
return err
209+
}
210+
211+
err = saveAppToJSON(ctx, clients, *app)
212+
if err != nil {
213+
clients.IO.PrintDebug(ctx, "Error saving app to file when linking existing app: %s", err)
214+
return err
215+
}
216+
217+
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
218+
Emoji: "house",
219+
Text: "App",
220+
Secondary: formatListSuccess([]types.App{*app}),
221+
}))
222+
223+
return nil
224+
}
225+
195226
// LinkAppFooterSection displays the details of app that was added to the project.
196227
func LinkAppFooterSection(ctx context.Context, clients *shared.ClientFactory, app *types.App) {
197228
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{

cmd/project/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []
229229
defer func() {
230230
_ = os.Chdir(originalDir)
231231
}()
232-
if err := app.LinkExistingApp(ctx, clients, &types.App{}, false); err != nil {
232+
if err := app.LinkExistingAppQuiet(ctx, clients, &types.App{}); err != nil {
233233
return err
234234
}
235235
}

0 commit comments

Comments
 (0)