summaryrefslogtreecommitdiff
path: root/alot/__main__.py
diff options
context:
space:
mode:
authorAlexander Shpilkin <ashpilkin@gmail.com>2018-07-24 23:06:59 +0200
committerAlexander Shpilkin <ashpilkin@gmail.com>2018-07-25 00:39:56 +0200
commit474f7c8477ed6c88c56815a09cc98a7cabc4f70d (patch)
tree4a605380a975169336948f3921e90ceb032fd980 /alot/__main__.py
parentbdaebeb9c82382c06da6fbbda5ebd0f60bdf3f28 (diff)
Describe options the same way in help and manual
The descriptions of --help and --version are the same as used in e.g. GNU coreutils (different from the Python default).
Diffstat (limited to 'alot/__main__.py')
-rw-r--r--alot/__main__.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/alot/__main__.py b/alot/__main__.py
index 1c2a2c46..221e6b22 100644
--- a/alot/__main__.py
+++ b/alot/__main__.py
@@ -23,35 +23,40 @@ _SUBCOMMANDS = ['search', 'compose', 'bufferlist', 'taglist', 'namedqueries',
def parser():
"""Parse command line arguments, validate them, and return them."""
- parser = argparse.ArgumentParser()
- parser.add_argument('-v', '--version', action='version',
- version=alot.__version__)
+ parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-r', '--read-only', action='store_true',
help='open notmuch database in read-only mode')
- parser.add_argument('-c', '--config',
+ parser.add_argument('-c', '--config', metavar='FILENAME',
action=cargparse.ValidatedStoreAction,
validator=cargparse.require_file,
help='configuration file')
- parser.add_argument('-n', '--notmuch-config', default=os.environ.get(
+ parser.add_argument('-n', '--notmuch-config', metavar='FILENAME',
+ default=os.environ.get(
'NOTMUCH_CONFIG',
os.path.expanduser('~/.notmuch-config')),
action=cargparse.ValidatedStoreAction,
validator=cargparse.require_file,
help='notmuch configuration file')
- parser.add_argument('-C', '--colour-mode',
+ parser.add_argument('-C', '--colour-mode', metavar='COLOURS',
choices=(1, 16, 256), type=int,
help='number of colours to use')
- parser.add_argument('-p', '--mailindex-path',
+ parser.add_argument('-p', '--mailindex-path', metavar='PATH',
action=cargparse.ValidatedStoreAction,
validator=cargparse.require_dir,
help='path to notmuch index')
- parser.add_argument('-d', '--debug-level', default='info',
+ parser.add_argument('-d', '--debug-level', metavar='LEVEL', default='info',
choices=('debug', 'info', 'warning', 'error'),
help='debug level [default: %(default)s]')
- parser.add_argument('-l', '--logfile', default='/dev/null',
+ parser.add_argument('-l', '--logfile', metavar='FILENAME',
+ default='/dev/null',
action=cargparse.ValidatedStoreAction,
validator=cargparse.optional_file_like,
help='log file [default: %(default)s]')
+ parser.add_argument('-h', '--help', action='help',
+ help='display this help and exit')
+ parser.add_argument('-v', '--version', action='version',
+ version=alot.__version__,
+ help='output version information and exit')
# We will handle the subcommands in a separate run of argparse as argparse
# does not support optional subcommands until now.
parser.add_argument('command', nargs=argparse.REMAINDER,