Refactor arg parsing into own function
This commit is contained in:
parent
e1bce18d2d
commit
97bcca145b
@ -36,136 +36,136 @@ def try_deleting(files):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def build_argument_parser(args):
|
||||||
p = ArgumentParser(
|
parser = ArgumentParser(
|
||||||
"Check for pads that have changed since last sync (according to .meta.json)"
|
"Check for pads that have changed since last sync (according to .meta.json)"
|
||||||
)
|
)
|
||||||
|
parser.add_argument("padid", nargs="*", default=[])
|
||||||
p.add_argument("padid", nargs="*", default=[])
|
parser.add_argument(
|
||||||
p.add_argument(
|
|
||||||
"--glob", default=False, help="download pads matching a glob pattern"
|
"--glob", default=False, help="download pads matching a glob pattern"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
p.add_argument(
|
|
||||||
"--padinfo",
|
"--padinfo",
|
||||||
default=".etherpump/settings.json",
|
default=".etherpump/settings.json",
|
||||||
help="settings, default: .etherpump/settings.json",
|
help="settings, default: .etherpump/settings.json",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--zerorevs",
|
"--zerorevs",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="include pads with zero revisions, default: False (i.e. pads with no revisions are skipped)",
|
help="include pads with zero revisions, default: False (i.e. pads with no revisions are skipped)",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--pub",
|
"--pub",
|
||||||
default="p",
|
default="p",
|
||||||
help="folder to store files for public pads, default: p",
|
help="folder to store files for public pads, default: p",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--group",
|
"--group",
|
||||||
default="g",
|
default="g",
|
||||||
help="folder to store files for group pads, default: g",
|
help="folder to store files for group pads, default: g",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--skip",
|
"--skip",
|
||||||
default=None,
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
help="skip this many items, default: None",
|
help="skip this many items, default: None",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--meta",
|
"--meta",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="download meta to PADID.meta.json, default: False",
|
help="download meta to PADID.meta.json, default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--text",
|
"--text",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="download text to PADID.txt, default: False",
|
help="download text to PADID.txt, default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--html",
|
"--html",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="download html to PADID.html, default: False",
|
help="download html to PADID.html, default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--dhtml",
|
"--dhtml",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="download dhtml to PADID.diff.html, default: False",
|
help="download dhtml to PADID.diff.html, default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--all",
|
"--all",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="download all files (meta, text, html, dhtml), default: False",
|
help="download all files (meta, text, html, dhtml), default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--folder",
|
"--folder",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="dump files in a folder named PADID (meta, text, html, dhtml), default: False",
|
help="dump files in a folder named PADID (meta, text, html, dhtml), default: False",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--output",
|
"--output",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="output changed padids on stdout",
|
help="output changed padids on stdout",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--force",
|
"--force",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="reload, even if revisions count matches previous",
|
help="reload, even if revisions count matches previous",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--no-raw-ext",
|
"--no-raw-ext",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="save plain text as padname with no (additional) extension",
|
help="save plain text as padname with no (additional) extension",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--fix-names",
|
"--fix-names",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="normalize padid's (no spaces, special control chars) for use in file names",
|
help="normalize padid's (no spaces, special control chars) for use in file names",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
p.add_argument(
|
|
||||||
"--filter-ext", default=None, help="filter pads by extension"
|
"--filter-ext", default=None, help="filter pads by extension"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
p.add_argument(
|
|
||||||
"--css",
|
"--css",
|
||||||
default="/styles.css",
|
default="/styles.css",
|
||||||
help="add css url to output pages, default: /styles.css",
|
help="add css url to output pages, default: /styles.css",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--script",
|
"--script",
|
||||||
default="/versions.js",
|
default="/versions.js",
|
||||||
help="add script url to output pages, default: /versions.js",
|
help="add script url to output pages, default: /versions.js",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
p.add_argument(
|
|
||||||
"--nopublish",
|
"--nopublish",
|
||||||
default="__NOPUBLISH__",
|
default="__NOPUBLISH__",
|
||||||
help="no publish magic word, default: __NOPUBLISH__",
|
help="no publish magic word, default: __NOPUBLISH__",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--publish",
|
"--publish",
|
||||||
default="__PUBLISH__",
|
default="__PUBLISH__",
|
||||||
help="the publish magic word, default: __PUBLISH__",
|
help="the publish magic word, default: __PUBLISH__",
|
||||||
)
|
)
|
||||||
p.add_argument(
|
parser.add_argument(
|
||||||
"--publish-opt-in",
|
"--publish-opt-in",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="ensure `--publish` is honoured instead of `--nopublish`",
|
help="ensure `--publish` is honoured instead of `--nopublish`",
|
||||||
)
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
p = build_argument_parser(args)
|
||||||
args = p.parse_args(args)
|
args = p.parse_args(args)
|
||||||
|
|
||||||
raw_ext = ".raw.txt"
|
raw_ext = ".raw.txt"
|
||||||
|
Loading…
Reference in New Issue
Block a user