Skip to content

Commit cf6a674

Browse files
committed
fix: --name flag overrides display name without replacing path argument
The --name flag now only sets the manifest display name, preserving any path provided via the positional argument for directory placement.
1 parent bdeadda commit cf6a674

3 files changed

Lines changed: 38 additions & 21 deletions

File tree

cmd/project/create.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []
116116
}
117117
}
118118

119-
// --name flag overrides any positional app name argument
120-
// This allows users to name their app "agent" without triggering the AI Agent shortcut
119+
// --name flag overrides the manifest display name but preserves any path
120+
// from the positional argument. When no positional arg is given (e.g.
121+
// "slack create --name APPPP"), the name flag also becomes the directory
122+
// path since there's nothing else to derive it from.
123+
displayNameOverride := ""
121124
if nameFlagProvided {
122-
appNameArg = createAppNameFlag
125+
displayNameOverride = createAppNameFlag
126+
if appNameArg == "" {
127+
appNameArg = createAppNameFlag
128+
}
123129
}
124130

125131
// List templates and exit early if the --list flag is set
@@ -164,10 +170,11 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []
164170
subdir = template.GetSubdir()
165171
}
166172
createArgs := create.CreateArgs{
167-
AppName: appNameArg,
168-
Template: template,
169-
GitBranch: createGitBranchFlag,
170-
Subdir: subdir,
173+
AppName: appNameArg,
174+
DisplayName: displayNameOverride,
175+
Template: template,
176+
GitBranch: createGitBranchFlag,
177+
Subdir: subdir,
171178
}
172179
clients.EventTracker.SetAppTemplate(template.GetTemplatePath())
173180

cmd/project/create_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ func TestCreateCommand(t *testing.T) {
304304
template, err := create.ResolveTemplateURL("slack-samples/bolt-js-starter-template")
305305
require.NoError(t, err)
306306
expected := create.CreateArgs{
307-
AppName: "agent",
308-
Template: template,
307+
AppName: "agent",
308+
DisplayName: "agent",
309+
Template: template,
309310
}
310311
createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, expected)
311312
// Verify that category prompt WAS called (shortcut was not triggered)
@@ -351,9 +352,10 @@ func TestCreateCommand(t *testing.T) {
351352
require.NoError(t, err)
352353
template.SetSubdir("claude-agent-sdk")
353354
expected := create.CreateArgs{
354-
AppName: "my-custom-name", // --name flag overrides
355-
Template: template,
356-
Subdir: "claude-agent-sdk",
355+
AppName: "my-custom-name", // --name flag used as path when no positional arg
356+
DisplayName: "my-custom-name",
357+
Template: template,
358+
Subdir: "claude-agent-sdk",
357359
}
358360
createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, expected)
359361
// Verify that category prompt was NOT called (shortcut was triggered)
@@ -387,8 +389,9 @@ func TestCreateCommand(t *testing.T) {
387389
template, err := create.ResolveTemplateURL("slack-samples/bolt-js-starter-template")
388390
require.NoError(t, err)
389391
expected := create.CreateArgs{
390-
AppName: "my-name", // --name flag overrides "my-project" positional arg
391-
Template: template,
392+
AppName: "my-project", // positional arg preserved as path
393+
DisplayName: "my-name", // --name flag sets manifest display name
394+
Template: template,
392395
}
393396
createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, expected)
394397
// Verify that name prompt was NOT called since --name flag was provided
@@ -432,9 +435,10 @@ func TestCreateCommand(t *testing.T) {
432435
require.NoError(t, err)
433436
template.SetSubdir("claude-agent-sdk")
434437
expected := create.CreateArgs{
435-
AppName: "my-name", // --name flag overrides "my-project" positional arg
436-
Template: template,
437-
Subdir: "claude-agent-sdk",
438+
AppName: "my-project", // positional arg preserved as path
439+
DisplayName: "my-name", // --name flag sets manifest display name
440+
Template: template,
441+
Subdir: "claude-agent-sdk",
438442
}
439443
createClientMock.AssertCalled(t, "Create", mock.Anything, mock.Anything, expected)
440444
// Verify that category prompt was NOT called (agent shortcut was triggered)

internal/pkg/create/create.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ var copyIgnoreFiles = []string{".DS_Store"}
5050

5151
// CreateArgs are the arguments passed into the Create function
5252
type CreateArgs struct {
53-
AppName string
54-
Template Template
55-
GitBranch string
56-
Subdir string
53+
AppName string
54+
DisplayName string
55+
Template Template
56+
GitBranch string
57+
Subdir string
5758
}
5859

5960
// Create will create a new Slack app on the file system and app manifest on the Slack API.
@@ -73,6 +74,11 @@ func Create(ctx context.Context, clients *shared.ClientFactory, createArgs Creat
7374
return "", slackerror.Wrap(err, slackerror.ErrAppDirectoryAccess)
7475
}
7576

77+
// --name flag overrides only the display name, preserving the path from the argument
78+
if createArgs.DisplayName != "" {
79+
displayName = createArgs.DisplayName
80+
}
81+
7682
// Get the project's full directory path
7783
projectDirPath := ""
7884
if filepath.IsLocal(appPath) {

0 commit comments

Comments
 (0)