From 97bcca145bd7ba2d8b48dc7867afcd83fb3a524e Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 18 Jan 2020 23:39:07 +0100 Subject: [PATCH] Refactor arg parsing into own function --- etherpump/commands/pull.py | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/etherpump/commands/pull.py b/etherpump/commands/pull.py index 235ccfd..82fb627 100644 --- a/etherpump/commands/pull.py +++ b/etherpump/commands/pull.py @@ -36,136 +36,136 @@ def try_deleting(files): pass -def main(args): - p = ArgumentParser( +def build_argument_parser(args): + parser = ArgumentParser( "Check for pads that have changed since last sync (according to .meta.json)" ) - - p.add_argument("padid", nargs="*", default=[]) - p.add_argument( + parser.add_argument("padid", nargs="*", default=[]) + parser.add_argument( "--glob", default=False, help="download pads matching a glob pattern" ) - - p.add_argument( + parser.add_argument( "--padinfo", default=".etherpump/settings.json", help="settings, default: .etherpump/settings.json", ) - p.add_argument( + parser.add_argument( "--zerorevs", default=False, action="store_true", help="include pads with zero revisions, default: False (i.e. pads with no revisions are skipped)", ) - p.add_argument( + parser.add_argument( "--pub", default="p", help="folder to store files for public pads, default: p", ) - p.add_argument( + parser.add_argument( "--group", default="g", help="folder to store files for group pads, default: g", ) - p.add_argument( + parser.add_argument( "--skip", default=None, type=int, help="skip this many items, default: None", ) - p.add_argument( + parser.add_argument( "--meta", default=False, action="store_true", help="download meta to PADID.meta.json, default: False", ) - p.add_argument( + parser.add_argument( "--text", default=False, action="store_true", help="download text to PADID.txt, default: False", ) - p.add_argument( + parser.add_argument( "--html", default=False, action="store_true", help="download html to PADID.html, default: False", ) - p.add_argument( + parser.add_argument( "--dhtml", default=False, action="store_true", help="download dhtml to PADID.diff.html, default: False", ) - p.add_argument( + parser.add_argument( "--all", default=False, action="store_true", help="download all files (meta, text, html, dhtml), default: False", ) - p.add_argument( + parser.add_argument( "--folder", default=False, action="store_true", help="dump files in a folder named PADID (meta, text, html, dhtml), default: False", ) - p.add_argument( + parser.add_argument( "--output", default=False, action="store_true", help="output changed padids on stdout", ) - p.add_argument( + parser.add_argument( "--force", default=False, action="store_true", help="reload, even if revisions count matches previous", ) - p.add_argument( + parser.add_argument( "--no-raw-ext", default=False, action="store_true", help="save plain text as padname with no (additional) extension", ) - p.add_argument( + parser.add_argument( "--fix-names", default=False, action="store_true", help="normalize padid's (no spaces, special control chars) for use in file names", ) - - p.add_argument( + parser.add_argument( "--filter-ext", default=None, help="filter pads by extension" ) - - p.add_argument( + parser.add_argument( "--css", default="/styles.css", help="add css url to output pages, default: /styles.css", ) - p.add_argument( + parser.add_argument( "--script", default="/versions.js", help="add script url to output pages, default: /versions.js", ) - - p.add_argument( + parser.add_argument( "--nopublish", default="__NOPUBLISH__", help="no publish magic word, default: __NOPUBLISH__", ) - p.add_argument( + parser.add_argument( "--publish", default="__PUBLISH__", help="the publish magic word, default: __PUBLISH__", ) - p.add_argument( + parser.add_argument( "--publish-opt-in", default=False, action="store_true", help="ensure `--publish` is honoured instead of `--nopublish`", ) + return parser + + +def main(args): + p = build_argument_parser(args) args = p.parse_args(args) raw_ext = ".raw.txt"