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

Allow removing a template using the CLI #75

Open
alicenstar opened this issue Aug 10, 2023 · 5 comments
Open

Allow removing a template using the CLI #75

alicenstar opened this issue Aug 10, 2023 · 5 comments

Comments

@alicenstar
Copy link

I'd like for there to be a way to delete templates using the CLI. We are managing our templates using a GitHub repository, and this poses some difficulty in maintaining the templates long term.

@tomek-ac
Copy link
Contributor

@alicenstar can you give us some more context? How would you like this to work?

@alicenstar
Copy link
Author

@tomek-ac I'm flexible in implementation but it'd be nice to be able to do something like postmark template -d template-name. Or adding this functionality to the API would be helpful as well.

@alicenstar
Copy link
Author

My team was trying to set up a way to manage postmark templates in a repository using GitHub Actions and the Postmark CLI, but the only case we can't handle is if we want to delete a template.

@rlueder
Copy link

rlueder commented Sep 30, 2023

@alicenstar I opened a PR here which includes a basic delete command, keep in mind it'll delete ALL templates as that's what I currently need for my use case but should be easy enough to tweak and allow deleting a single template by id/alias or a list of templates.

I was having too much fun with this one and improved the UX by allowing users to select whether they want to delete by id (one or multiple) or delete all templates. :)

Also added some extra check for delete all as it can be quite destructive.

The underlying Postmark client already included a deleteTemplate method so it was easy enough to expose to the CLI.

To use it locally run:

$ npm run build

then

$ ./dist/index.js templates delete

> ./dist/index.js templates delete
? Please enter your server token ••••••••••••••••••••••••••••••••••••
? Choose how you want to delete templates: Delete templates by id
? Enter template id(s) - separated by commas if multiple: 33336536, 33336535, 33336549
All finished! 3 templates have been deleted.
> ./dist/index.js templates delete
? Please enter your server token ••••••••••••••••••••••••••••••••••••
? Choose how you want to delete templates: Delete all templates
? Which template type do you want to delete? Templates
? Delete ALL templates? Are you sure? yes
? Enter "delete all templates" to confirm: delete all templates
All finished! 80 templates have been deleted.

@tomek-ac
Copy link
Contributor

tomek-ac commented Oct 2, 2023

@rlueder thanks for working on this!

@alicenstar what do you think? Would this work in your case? The proposed implementation seems to require providing the parameters interactively so it will probably not work in a hands-free GH action?

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

No branches or pull requests

3 participants