Skip to content

Allow removing a template using the CLI #75

Open

Description

@alicenstar

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.

Activity

  1. tomek-ac commented on Aug 17, 2023

    @tomek-ac
    Contributor

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

  2. alicenstar commented on Sep 22, 2023

    @alicenstar
    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.

  3. alicenstar commented on Sep 22, 2023

    @alicenstar
    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.

  4. rlueder commented on Sep 30, 2023

    @rlueder

    @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.
    
  5. tomek-ac commented on Oct 2, 2023

    @tomek-ac
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions