Grouped help.

This commit is contained in:
Arun Prakash Jana 2016-04-27 02:43:27 +05:30
parent 7affa00442
commit 1549f51bf8
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB

112
buku
View File

@ -975,16 +975,16 @@ class ExtendedArgumentParser(argparse.ArgumentParser):
# Print additional help and info
@staticmethod
def print_extended_help(file=None):
file.write(textwrap.dedent("""
file.write(textwrap.dedent('''
prompt keys:
1-N open the Nth search result in web browser
Enter exit buku
1-N open the Nth search result in web browser
Enter exit buku
Version %.1f
Copyright (C) 2015 Arun Prakash Jana <engineerarun@gmail.com>
License: GPLv3
Webpage: https://github.com/jarun/buku
""" % _VERSION_))
''' % _VERSION_))
# Help
def print_help(self, file=None):
@ -1024,56 +1024,66 @@ argparser = ExtendedArgumentParser(
add_help=False
)
general_group = argparser.add_argument_group(title="general options")
general_group.add_argument('-a', '--add', nargs='+', dest='addurl', metavar=('URL', 'tags'),
help="bookmark URL with comma separated tags")
general_group.add_argument('-u', '--update', nargs='*', dest='update', action=customAction, metavar=('N', 'URL tags'),
help="update fields of bookmark at DB index N\n"
"if URL is omitted (and -m unused), refresh\n"
"title of bookmark at index N from the web;\n"
"refresh all titles, if N is omitted")
general_group.add_argument('-t', '--title', nargs='+', dest='titleManual', metavar='title',
help="manually set title, works with -a, -u\n"
"title='blank': no title")
general_group.add_argument('-d', '--delete', nargs='?', dest='delete', type=int, const=0, metavar='N',
help="delete bookmark at DB index N (from -p 0)\n"
"delete all bookmarks, if N is omitted")
general_group.add_argument('-h', '--help', dest='help', action='store_true',
help="show this information")
# General options
general_group = argparser.add_argument_group(title="general options",
description='''-a, --add URL [tags ...]
bookmark URL with comma separated tags
-u, --update [N [URL tags ...]]
update fields of bookmark at DB index N
refresh all titles, if no arguments
if URL omitted and -t is unused, update
title of bookmark at index N from web
-t, --title title [...]
manually set title, works with -a, -u
title='blank': no title
-d, --delete [N] delete bookmark at DB index N
delete all bookmarks, if no arguments
-h, --help show this information''')
general_group.add_argument('-a', '--add', nargs='+', dest='addurl', metavar=('URL', 'tags'), help=argparse.SUPPRESS)
general_group.add_argument('-u', '--update', nargs='*', dest='update', action=customAction, metavar=('N', 'URL tags'), help=argparse.SUPPRESS)
general_group.add_argument('-t', '--title', nargs='+', dest='titleManual', metavar='title', help=argparse.SUPPRESS)
general_group.add_argument('-d', '--delete', nargs='?', dest='delete', type=int, const=0, metavar='N', help=argparse.SUPPRESS)
general_group.add_argument('-h', '--help', dest='help', action='store_true', help=argparse.SUPPRESS)
search_group=argparser.add_argument_group(title="search options")
search_group.add_argument('-s', '--sany', nargs='+', metavar='keyword',
help="search bookmarks for ANY matching keyword")
search_group.add_argument('-S', '--sall', nargs='+', metavar='keyword',
help="search bookmarks with ALL keywords\n"
"special keywords:\n"
"'tags' - list all tags alphabetically\n"
"'blank'- list entries with empty title/tag")
# Search options
search_group=argparser.add_argument_group(title="search options",
description='''-s, --sany keyword [...]
search bookmarks for ANY matching keyword
-S, --sall keyword [...]
search bookmarks with ALL keywords
special keywords -
"tags" : list all tags alphabetically
"blank": list entries with empty title/tag''')
search_group.add_argument('-s', '--sany', nargs='+', metavar='keyword', help=argparse.SUPPRESS)
search_group.add_argument('-S', '--sall', nargs='+', metavar='keyword', help=argparse.SUPPRESS)
crypto_group=argparser.add_argument_group(title="encryption options")
crypto_group.add_argument('-k', '--unlock', nargs='?', dest='decrypt', type=int, const=8, metavar='N',
help="decrypt DB file with N (> 0, default 8)\n"
"hash iterations to generate key")
crypto_group.add_argument('-l', '--lock', nargs='?', dest='encrypt', type=int, const=8, metavar='N',
help="encrypt DB file with N (> 0, default 8)\n"
"hash iterations to generate key")
# Encryption options
crypto_group=argparser.add_argument_group(title="encryption options",
description='''-l, --lock [N] encrypt DB file with N (> 0, default 8)
hash iterations to generate key
-k, --unlock [N] decrypt DB file with N (> 0, default 8)
hash iterations to generate key''')
crypto_group.add_argument('-k', '--unlock', nargs='?', dest='decrypt', type=int, const=8, metavar='N', help=argparse.SUPPRESS)
crypto_group.add_argument('-l', '--lock', nargs='?', dest='encrypt', type=int, const=8, metavar='N', help=argparse.SUPPRESS)
power_group=argparser.add_argument_group(title="power toys")
power_group.add_argument('-p', '--print', nargs='?', dest='printindex', type=int, const=0, metavar='N',
help="show details of bookmark at DB index N\n"
"show all bookmarks, if N is omitted")
power_group.add_argument('-f', '--format', dest='showOpt', type=int, choices=[1, 2], metavar='N',
help="modify -p output\n"
"N=1: show only URL, N=2: show URL and tag")
power_group.add_argument('-r', '--replace', nargs=2, dest='replace', metavar=('oldtag', 'newtag'),
help="replace oldtag with newtag for all bookmarks\n"
"newtag='blank': delete oldtag")
power_group.add_argument('-j', '--json', dest='jsonOutput', action='store_true',
help="Json formatted output, works with -p, -s")
power_group.add_argument('-o', '--open', dest='openurl', type=int, metavar='N',
help="open bookmark at DB index N in web browser")
power_group.add_argument('-z', '--debug', dest='debug', action='store_true',
help="show debug information and additional logs")
# Power toys
power_group=argparser.add_argument_group(title="power toys",
description='''-p, --print [N] show details of bookmark at DB index N
show all bookmarks, if no arguments
-f, --format N modify -p output
N=1: show only URL, N=2: show URL and tag
-r, --replace oldtag newtag
replace oldtag with newtag for all bookmarks
newtag='blank': delete oldtag
-j, --jason Json formatted output, works with -p, -s
-o, --open open bookmark at DB index N in web browser
-z, --debug show debug information and additional logs''')
power_group.add_argument('-p', '--print', nargs='?', dest='printindex', type=int, const=0, metavar='N', help=argparse.SUPPRESS)
power_group.add_argument('-f', '--format', dest='showOpt', type=int, choices=[1, 2], metavar='N', help=argparse.SUPPRESS)
power_group.add_argument('-r', '--replace', nargs=2, dest='replace', metavar=('oldtag', 'newtag'), help=argparse.SUPPRESS)
power_group.add_argument('-j', '--json', dest='jsonOutput', action='store_true', help=argparse.SUPPRESS)
power_group.add_argument('-o', '--open', dest='openurl', type=int, metavar='N', help=argparse.SUPPRESS)
power_group.add_argument('-z', '--debug', dest='debug', action='store_true', help=argparse.SUPPRESS)
#addarg = argparser.add_argument
#addarg('-i', '--insert', nargs='+', dest='insert', metavar=('N', 'URL tags'),