From 03a513b8b6228d8ff933a5c37d54fc775d797a9b Mon Sep 17 00:00:00 2001 From: anbosuki Date: Mon, 4 Jul 2022 19:22:35 +0200 Subject: [PATCH] cli-delete-posts Added the possibility to delete single posts or a range of multiple posts at once using the command as following:
`docker-compose run server ./szuru-admin --delete posts 35 36 40-45`
Each space represents a single post id, using a `-` between two ids will delete all posts within range, including the first and the last one --- server/szuru-admin | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/szuru-admin b/server/szuru-admin index ee5fa69f..dd0279e7 100755 --- a/server/szuru-admin +++ b/server/szuru-admin @@ -101,12 +101,9 @@ def regenerate_thumbnails() -> None: def delete_posts(parameters: list) -> None: - verification: str = "y" + verification: str = input("Do you really want to delete all posts with the given ID's [y/n]: ").lower() - while "" == verification: - verification = input("Do you really want to delete all posts with the given ID's [y/n]: ") - - if "y" != verification.lower(): + if "y" != verification: return def delete_one_post(post_id: int) -> None: @@ -175,8 +172,9 @@ def main() -> None: "--delete-posts", metavar="", nargs='+', - help="Will delete all posts with the given id's, all id's are seperated by a space. " - "If you want to delete a range of posts use it like: 37-47 (including the first and last number)" + help="Delete all posts with the specified ID, separated by a space. " + "Multiple posts can be deleted at once by specifying them as follows, " + "including the upper and lower limits: 37-47" ) command = parser_top.parse_args()