Change debug option to "print stdout" / "edit wiki" in the Refresh activities script

This commit is contained in:
Yohann D'ANELLO 2020-09-05 00:45:10 +02:00
parent 2a113d22b9
commit 7246f4d18a
1 changed files with 10 additions and 9 deletions

View File

@ -150,30 +150,31 @@ class Command(BaseCommand):
return page, header + body return page, header + body
@staticmethod @staticmethod
def refresh_raw_wiki_page(comment="refresh", debug=True): def refresh_raw_wiki_page(comment="refresh", print_stdout=False, edit_wiki=False):
page, content = Command.get_raw_page() page, content = Command.get_raw_page()
if debug: if print_stdout:
print(content) print(content)
else: if edit_wiki:
Command.edit_wiki(page, content, comment) Command.edit_wiki(page, content, comment)
@staticmethod @staticmethod
def refresh_human_readable_wiki_page(comment="refresh", debug=True): def refresh_human_readable_wiki_page(comment="refresh", print_stdout=False, edit_wiki=False):
page, content = Command.get_human_readable_page() page, content = Command.get_human_readable_page()
if debug: if print_stdout:
print(content) print(content)
else: if edit_wiki:
Command.edit_wiki(page, content, comment) Command.edit_wiki(page, content, comment)
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument("--human", "-H", action="store_true", help="Save human readable page") parser.add_argument("--human", "-H", action="store_true", help="Save human readable page")
parser.add_argument("--raw", "-r", action="store_true", help="Save raw page, for the calendar") parser.add_argument("--raw", "-r", action="store_true", help="Save raw page, for the calendar")
parser.add_argument("--comment", "-c", action="store", type=str, default="", help="Comment of the modification") parser.add_argument("--comment", "-c", action="store", type=str, default="", help="Comment of the modification")
parser.add_argument("--debug", "-d", action="store_true", help="Don't commit to the wiki, render in stdout") parser.add_argument("--stdout", "-o", action="store_true", help="Render the wiki page in stdout")
parser.add_argument("--wiki", "-w", action="store_true", help="Send modifications to the wiki")
def handle(self, *args, **options): def handle(self, *args, **options):
if options["raw"]: if options["raw"]:
Command.refresh_raw_wiki_page(options["comment"], options["debug"]) Command.refresh_raw_wiki_page(options["comment"], options["stdout"], options["wiki"])
if options["human"]: if options["human"]:
Command.refresh_human_readable_wiki_page(options["comment"], options["debug"]) Command.refresh_human_readable_wiki_page(options["comment"], options["stdout"], options["wiki"])