Skip to content
Snippets Groups Projects
Commit 1375ec5b authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Show the list of supported file types in the manual and --help output. We can...

Show the list of supported file types in the manual and --help output. We can copy-paste this into the website, at least. Thanks to Jonathan Dowland for the suggestion. (Closes: #893443)
parent 0ca1403f
No related branches found
No related tags found
No related merge requests found
......@@ -126,3 +126,10 @@ class ComparatorManager(object):
))
logger.debug("Loaded %d comparator classes", len(self.classes))
def get_descriptions(self):
for x in self.classes:
try:
yield x.DESCRIPTION
except AttributeError:
pass
......@@ -73,7 +73,7 @@ class BooleanAction(argparse.Action):
def create_parser():
parser = argparse.ArgumentParser(
description='Calculate differences between two files or directories',
add_help=False)
add_help=False, formatter_class=HelpFormatter)
parser.add_argument('path1', nargs='?', help='First file or directory to '
'compare. If omitted, tries to read a diffoscope diff from stdin.')
parser.add_argument('path2', nargs='?', help='Second file or directory to '
......@@ -265,6 +265,15 @@ def create_parser():
return parser, post_parse
class HelpFormatter(argparse.HelpFormatter):
def format_help(self, *args, **kwargs):
val = super().format_help(*args, **kwargs)
val = '{}\n\nfile formats supported:\n'.format(val)
for x in sorted(ComparatorManager().get_descriptions(), key=str.title):
val = '{}{}- {}{}.\n\n'.format(val, ' ' * 24, x[0].upper(), x[1:])
return val
class RangeCompleter(object):
def __init__(self, start, end=0, divisions=16):
if end < start:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment