@@ -32,9 +32,6 @@ import (
3232 "github.com/spf13/cobra"
3333)
3434
35- // LinkAppConfirmPromptText is displayed when prompting to add an existing app
36- const LinkAppConfirmPromptText = "Do you want to add an existing app?"
37-
3835// appLinkFlagSet contains flag values to reference
3936type appLinkFlagSet struct {
4037 environmentFlag string
@@ -97,58 +94,8 @@ func LinkCommandRunE(ctx context.Context, clients *shared.ClientFactory, app *ty
9794 // Add empty line between executed command and first output
9895 clients .IO .PrintInfo (ctx , false , "" )
9996
100- err = LinkExistingApp (ctx , clients , app , false )
101- if err != nil {
102- return err
103- }
104-
105- return nil
106- }
107-
108- // LinkAppHeaderSection displays a section explaining how to find existing apps.
109- // External callers can use extraSecondaryText to show additional information.
110- // When shouldConfirm is true, additional information is included in the header
111- // explaining how to link apps, in case the user declines.
112- func LinkAppHeaderSection (ctx context.Context , clients * shared.ClientFactory , shouldConfirm bool ) {
113- var secondaryText = []string {
114- "Add an existing app from app settings" ,
115- "Find your existing apps at: " + style .Underline ("https://api.slack.com/apps" ),
116- }
117-
118- if shouldConfirm {
119- secondaryText = append (secondaryText , "Manually add apps later with " + style .Commandf ("app link" , true ))
120- }
121-
122- clients .IO .PrintInfo (ctx , false , "%s" , style .Sectionf (style.TextSection {
123- Emoji : "house" ,
124- Text : "App Link" ,
125- Secondary : secondaryText ,
126- }))
127- }
128-
129- // LinkExistingApp prompts for an existing App ID and saves the details to the project.
130- // When shouldConfirm is true, a confirmation prompt will ask the user if they want to
131- // link an existing app and additional information is included in the header.
132- // The shouldConfirm option is encouraged for third-party callers.
133- func LinkExistingApp (ctx context.Context , clients * shared.ClientFactory , app * types.App , shouldConfirm bool ) (err error ) {
13497 // Header section
135- LinkAppHeaderSection (ctx , clients , shouldConfirm )
136-
137- // Confirm to add an existing app; useful for third-party callers
138- if shouldConfirm {
139- proceed , err := clients .IO .ConfirmPrompt (ctx , LinkAppConfirmPromptText , true )
140- if err != nil {
141- clients .IO .PrintDebug (ctx , "Error prompting to add an existing app: %s" , err )
142- return err
143- }
144-
145- // Add newline to match the trailing newline inserted from the footer section
146- clients .IO .PrintInfo (ctx , false , "" )
147-
148- if ! proceed {
149- return nil
150- }
151- }
98+ LinkAppHeaderSection (ctx , clients )
15299
153100 // App Manifest section
154101 manifestSource , err := clients .Config .ProjectConfig .GetManifestSource (ctx )
@@ -166,6 +113,45 @@ func LinkExistingApp(ctx context.Context, clients *shared.ClientFactory, app *ty
166113 },
167114 }))
168115
116+ err = LinkExistingApp (ctx , clients , app )
117+ if err != nil {
118+ return err
119+ }
120+
121+ // App summary section
122+ clients .IO .PrintInfo (ctx , false , "%s" , style .Sectionf (style.TextSection {
123+ Emoji : "house" ,
124+ Text : "App" ,
125+ Secondary : FormatListSuccess ([]types.App {* app }),
126+ }))
127+
128+ // Footer section
129+ clients .IO .PrintInfo (ctx , false , "%s" , style .Sectionf (style.TextSection {
130+ Emoji : "house_with_garden" ,
131+ Text : "App Link" ,
132+ Secondary : []string {
133+ "Added existing app to project" ,
134+ },
135+ }))
136+
137+ return nil
138+ }
139+
140+ // LinkAppHeaderSection displays a section explaining how to find existing apps.
141+ func LinkAppHeaderSection (ctx context.Context , clients * shared.ClientFactory ) {
142+ clients .IO .PrintInfo (ctx , false , "%s" , style .Sectionf (style.TextSection {
143+ Emoji : "house" ,
144+ Text : "App Link" ,
145+ Secondary : []string {
146+ "Add an existing app from app settings" ,
147+ "Find your existing apps at: " + style .Underline ("https://api.slack.com/apps" ),
148+ },
149+ }))
150+ }
151+
152+ // LinkExistingApp resolves app details, validates the app, and saves it to the
153+ // project. It produces no output — callers handle their own display.
154+ func LinkExistingApp (ctx context.Context , clients * shared.ClientFactory , app * types.App ) (err error ) {
169155 // Prompt to get app details
170156 var auth * types.SlackAuth
171157 * app , auth , err = promptExistingApp (ctx , clients )
@@ -186,28 +172,9 @@ func LinkExistingApp(ctx context.Context, clients *shared.ClientFactory, app *ty
186172 return err
187173 }
188174
189- // Footer section
190- LinkAppFooterSection (ctx , clients , app )
191-
192175 return nil
193176}
194177
195- // LinkAppFooterSection displays the details of app that was added to the project.
196- func LinkAppFooterSection (ctx context.Context , clients * shared.ClientFactory , app * types.App ) {
197- clients .IO .PrintInfo (ctx , false , "\n %s" , style .Sectionf (style.TextSection {
198- Emoji : "house" ,
199- Text : "App" ,
200- Secondary : formatListSuccess ([]types.App {* app }),
201- }))
202- clients .IO .PrintInfo (ctx , false , "%s" , style .Sectionf (style.TextSection {
203- Emoji : "house_with_garden" ,
204- Text : "App Link" ,
205- Secondary : []string {
206- "Added existing app to project" ,
207- },
208- }))
209- }
210-
211178// promptExistingApp gathers details to represent app information
212179func promptExistingApp (ctx context.Context , clients * shared.ClientFactory ) (types.App , * types.SlackAuth , error ) {
213180 slackAuth , err := prompts .PromptTeamSlackAuth (ctx , clients , "Select the existing app team" , nil )
0 commit comments