Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ make lint # Run golangci-lint
golangci-lint --version # Verify linter version
```

### Formatting

Always run `gofmt -w` on changed Go files after making edits to ensure proper formatting.

Comment on lines +34 to +37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Just adding this to scratch an itch where Claude fails to format files correctly.

### Other Commands

```bash
Expand Down
101 changes: 2 additions & 99 deletions cmd/project/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"github.com/slackapi/slack-cli/internal/iostreams"
"github.com/slackapi/slack-cli/internal/logger"
"github.com/slackapi/slack-cli/internal/pkg/create"
"github.com/slackapi/slack-cli/internal/shared"
"github.com/slackapi/slack-cli/internal/slackerror"
Expand All @@ -43,11 +42,6 @@ var createSubdirFlag string
// TODO - Find best practice, such as using an Interface and Struct to create a client
var CreateFunc = create.Create

var appCreateSpinner *style.Spinner

const copyTemplate = "Copying"
const cloneTemplate = "Cloning"

Comment on lines -46 to -50
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Removing because the spinner was never started in the current code.

// promptObject describes the Github app template
type promptObject struct {
Title string // "Reverse string"
Expand Down Expand Up @@ -93,9 +87,6 @@ name your app 'agent' (not create an AI Agent), use the --name flag instead.`,
func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

// Set up event logger
log := newCreateLogger(clients, cmd)

// Get optional app name passed as an arg and check for category shortcuts
appNameArg := ""
categoryShortcut := ""
Expand Down Expand Up @@ -166,9 +157,6 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []
}
}

// Set up spinners
appCreateSpinner = style.NewSpinner(cmd.OutOrStdout())

createArgs := create.CreateArgs{
AppName: appNameArg,
Template: template,
Expand All @@ -177,88 +165,15 @@ func runCreateCommand(clients *shared.ClientFactory, cmd *cobra.Command, args []
}
clients.EventTracker.SetAppTemplate(template.GetTemplatePath())

appDirPath, err := CreateFunc(ctx, clients, log, createArgs)
appDirPath, err := CreateFunc(ctx, clients, createArgs)
if err != nil {
printAppCreateError(clients, cmd, err)
return err
}

printCreateSuccess(ctx, clients, appDirPath)
return nil
}

/*
App creation is setting up local project directory
Events: on_app_create_completion
*/

// newCreateLogger creates a logger instance to receive event notifications
func newCreateLogger(clients *shared.ClientFactory, cmd *cobra.Command) *logger.Logger {
return logger.New(
// OnEvent
func(event *logger.LogEvent) {
switch event.Name {
case "on_app_create_template_default":
printAppCreateDefaultemplate(cmd, event)
case "on_app_create_template_custom":
printAppCreateCustomTemplate(cmd, event)
Comment on lines -200 to -203
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Neither of these events were ever called. This is why the spinner was never started.

case "on_app_create_completion":
printProjectCreateCompletion(clients, cmd, event)
Comment on lines -204 to -205
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This event was correctly called, but the spinner was never started so any calls to stop it are ignored.

default:
// Ignore the event
}
},
)
}

/*
App creation (not Create command) is cloning the template and creating the project directory
Events: on_app_create_template_custom, on_app_create_completion
*/

func printAppCreateDefaultemplate(cmd *cobra.Command, event *logger.LogEvent) {
startAppCreateSpinner(copyTemplate)
}

// Print template URL if using custom app template
func printAppCreateCustomTemplate(cmd *cobra.Command, event *logger.LogEvent) {
var verb string
templatePath := event.DataToString("templatePath")
isGit := event.DataToBool("isGit")
gitBranch := event.DataToString("gitBranch")

if isGit {
verb = cloneTemplate
} else {
verb = copyTemplate
}
templateText := fmt.Sprintf(
"%s template from %s",
verb,
templatePath,
)

if gitBranch != "" {
templateText = fmt.Sprintf("%s (branch: %s)", templateText, gitBranch)
}

cmd.Print(style.Secondary(templateText), "\n\n")

startAppCreateSpinner(verb)
}

func startAppCreateSpinner(verb string) {
appCreateSpinner.Update(verb+" app template", "").Start()
}

// Display message and added files at completion of app creation
func printProjectCreateCompletion(clients *shared.ClientFactory, cmd *cobra.Command, event *logger.LogEvent) {
createCompletionText := style.Sectionf(style.TextSection{
Emoji: "gear",
Text: "Created project directory",
})
appCreateSpinner.Update(createCompletionText, "").Stop()
}

// printCreateSuccess outputs an informative message after creating a new app
func printCreateSuccess(ctx context.Context, clients *shared.ClientFactory, appPath string) {
// Check if this is a Deno project to conditionally enable some features
Expand Down Expand Up @@ -318,15 +233,3 @@ func generateRandomAppName() string {
var randomName = fmt.Sprintf("%s-%s-%d", create.Adjectives[firstRandomNum], create.Animals[secondRandomNum], rand.Intn(1000))
return randomName
}

// printAppCreateError stops the creation spinners and displays the returned error message
func printAppCreateError(clients *shared.ClientFactory, cmd *cobra.Command, err error) {
ctx := cmd.Context()
switch {
case appCreateSpinner.Active():
errorText := fmt.Sprintf("Error creating project directory: %s", err)
appCreateSpinner.Update(errorText, "warning").Stop()
default:
}
clients.IO.PrintTrace(ctx, slacktrace.CreateError)
}
Loading
Loading