From 8368de7fa71f86cd9b783417a48d32b9fca0f5a0 Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Mon, 4 Jun 2018 23:32:13 +0200
Subject: [PATCH] Sort the output of `mat2 -l`

---
 libmat2/abstract.py | 4 ++--
 mat2                | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libmat2/abstract.py b/libmat2/abstract.py
index b7ccae9..7aac284 100644
--- a/libmat2/abstract.py
+++ b/libmat2/abstract.py
@@ -1,6 +1,6 @@
 import abc
 import os
-from typing import Set
+from typing import Set, Dict
 
 assert Set  # make pyflakes happy
 
@@ -15,7 +15,7 @@ class AbstractParser(abc.ABC):
         self.output_filename = fname + '.cleaned' + extension
 
     @abc.abstractmethod
-    def get_meta(self) -> dict:
+    def get_meta(self) -> Dict[str, str]:
         pass
 
     @abc.abstractmethod
diff --git a/mat2 b/mat2
index 11699f4..87fa66c 100755
--- a/mat2
+++ b/mat2
@@ -72,6 +72,7 @@ def clean_meta(params: Tuple[str, bool]) -> bool:
 
 def show_parsers():
     print('[+] Supported formats:')
+    formats = list()
     for parser in parser_factory._get_parsers():
         for mtype in parser.mimetypes:
             extensions = set()
@@ -82,7 +83,8 @@ def show_parsers():
                 # we're not supporting a single extension in the current
                 # mimetype, so there is not point in showing the mimetype at all
                 continue
-            print('  - %s (%s)' % (mtype, ', '.join(extensions)))
+            formats.append('  - %s (%s)' % (mtype, ', '.join(extensions)))
+    print('\n'.join(sorted(formats)))
 
 
 def __get_files_recursively(files):
-- 
GitLab