aboutsummaryrefslogtreecommitdiffstats
path: root/epy.py
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2022-01-15 12:04:37 +0700
committerbenadha <benawiadha@gmail.com>2022-01-15 12:04:37 +0700
commitbde59b1d0eeac75301459331e76df337b06f6749 (patch)
treec1912cff834766815172d9a52e4a14000f3608a5 /epy.py
parent3485dea872921b06a4640080d264e462fb0aec09 (diff)
downloadepy-bde59b1d0eeac75301459331e76df337b06f6749.tar.gz
Improve cli help interface
Diffstat (limited to 'epy.py')
-rwxr-xr-xepy.py60
1 files changed, 45 insertions, 15 deletions
diff --git a/epy.py b/epy.py
index 6f728e8..695cc81 100755
--- a/epy.py
+++ b/epy.py
@@ -1,18 +1,24 @@
#!/usr/bin/env python3
# vim:tabstop=4:shiftwidth=4:softtabstop=4:smarttab:expandtab:foldmethod=marker
"""\
-Usages:
- epy read last ebook
- epy EBOOKFILE read EBOOKFILE
- epy STRINGS read matched STRINGS from history
- epy NUMBER read file from history
- with associated NUMBER
-
-Options:
- -r print reading history
- -d dump epub
- -h, --help print help
- -v, --version print version
+usage: epy [-h] [-r] [-d] [-v] [EBOOK | #N | STRING ...]
+
+Read ebook in terminal
+
+positional arguments:
+ EBOOK | #N | STRING ebook path, history number or pattern
+
+optional arguments:
+ -h, --help show this help message and exit
+ -r, --history print reading history
+ -d, --dump dump the content of ebook
+ -v, --version print version and exit
+
+examples:
+ epy /path/to/ebook read /path/to/ebook file
+ epy 3 read #3 file from reading history
+ epy count monte read file matching 'count monte'
+ from reading history
"""
@@ -3751,12 +3757,36 @@ def parse_cli_args() -> Tuple[str, bool]:
Parse CLI args and return tuple of filepath and boolean (dump ebook indicator).
And exiting the program depending on situation.
"""
- args_parser = argparse.ArgumentParser(description="Read ebook in terminal")
+ prog = "epy"
+ args_parser = argparse.ArgumentParser(
+ prog=prog,
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ description="Read ebook in terminal",
+ epilog=textwrap.dedent(
+ f"""\
+ examples:
+ {prog} /path/to/ebook read /path/to/ebook file
+ {prog} 3 read #3 file from reading history
+ {prog} count monte read file matching 'count monte'
+ from reading history
+ """
+ ),
+ )
args_parser.add_argument("-r", "--history", action="store_true", help="print reading history")
args_parser.add_argument("-d", "--dump", action="store_true", help="dump the content of ebook")
- args_parser.add_argument("-v", "--version", action="version", version=f"v{__version__}")
args_parser.add_argument(
- "ebook", action="store", nargs="*", metavar="EBOOK", help="ebook path or history number"
+ "-v",
+ "--version",
+ action="version",
+ version=f"v{__version__}",
+ help="print version and exit",
+ )
+ args_parser.add_argument(
+ "ebook",
+ action="store",
+ nargs="*",
+ metavar="EBOOK | #N | STRING",
+ help="ebook path, history number or pattern",
)
args = args_parser.parse_args()