cli-delete-posts

Added the possibility to delete single posts or a range of multiple posts at once using the command as following:<br/>
`docker-compose run server ./szuru-admin --delete posts 35 36 40-45`<br/>
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
This commit is contained in:
anbosuki 2022-07-04 19:22:35 +02:00
parent 82b79461d6
commit 03a513b8b6

View file

@ -101,12 +101,9 @@ def regenerate_thumbnails() -> None:
def delete_posts(parameters: list) -> 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: if "y" != verification:
verification = input("Do you really want to delete all posts with the given ID's [y/n]: ")
if "y" != verification.lower():
return return
def delete_one_post(post_id: int) -> None: def delete_one_post(post_id: int) -> None:
@ -175,8 +172,9 @@ def main() -> None:
"--delete-posts", "--delete-posts",
metavar="<post_ids>", metavar="<post_ids>",
nargs='+', nargs='+',
help="Will delete all posts with the given id's, all id's are seperated by a space. " help="Delete all posts with the specified ID, separated by a space. "
"If you want to delete a range of posts use it like: 37-47 (including the first and last number)" "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() command = parser_top.parse_args()