Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗑️ Add delete-app command #24

Merged

Conversation

davidgaspardev
Copy link
Contributor

@davidgaspardev davidgaspardev commented Oct 12, 2024

Summary

This PR introduces a new command delete-app to the boneless CLI tool, allowing users to delete an existing app. The command ensures that critical components like app and bff cannot be deleted.

Changes

  1. Command Addition in main.go:

    • Added delete-app to the list of available commands.
    • Updated the help text to include the new delete-app command.
    • Implemented the delete-app command logic in the main function.
  2. New File delete.go:

    • Created a new file delete.go in the internal package.
    • Implemented the [DeleteApp] function to handle the deletion of app folders.
    • Added helper functions:
      • [validateAppName]: Ensures critical components cannot be deleted.
      • [checkIfAppFolderExists]: Checks if the app folder exists before attempting deletion.
      • [getAppFolderPath]: Constructs the path to the app folder based on the app name.

Usage

  • Command: boneless delete-app <app-name>
  • Example: boneless delete-app my-app

This command will delete the specified app folder if it exists and is not a critical component.

Testing

  • Verified that the delete-app command correctly deletes existing app folders.
  • Ensured that attempting to delete [app] or [bff] results in an appropriate error message and no deletion occurs.
  • Checked that non-existent app folders produce a "not found" error message.

Notes

  • This feature enhances the usability of the [boneless] CLI by providing a straightforward way to remove apps that are no longer needed.
  • Future improvements could include additional validation or confirmation prompts before deletion.

Added a new command "delete-app" to the boneless CLI tool. This command allows users to delete an app that was previously created. The command takes the app name as an argument and deletes the corresponding app folder from the internal directory. If the app folder does not exist, an error message is displayed. Upon successful deletion, a confirmation message is printed.
internal/delete.go Outdated Show resolved Hide resolved
Copy link
Owner

@renanbastos93 renanbastos93 left a comment

Choose a reason for hiding this comment

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

I am very happy with your contribution. I just made two suggestions. Thank you!

Refactor the delete.go file to handle errors gracefully when deleting an app folder or checking if the app folder exists. Instead of using os.Exit(1), the code now uses panic(err) to propagate the error. This ensures that the program terminates with an error message and stack trace, providing better debugging information.

Co-authored-by: renanbastos93 <renanbastos.tec@gmail.com>
internal/delete.go Outdated Show resolved Hide resolved
internal/delete.go Outdated Show resolved Hide resolved
internal/delete.go Outdated Show resolved Hide resolved
@renanbastos93 renanbastos93 merged commit c519eb2 into renanbastos93:main Oct 25, 2024
1 check passed
@davidgaspardev davidgaspardev deleted the feature/add-delete-app-command branch December 21, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants