summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2015-12-08 15:20:26 +0100
committerjvoisin2015-12-08 15:20:26 +0100
commitaa32b3dd050017d5876a924dd8ffb038285dc465 (patch)
treead88e9d9d9b94d417a07e782fd191c4bba40c29f
parent228ac6e11a3457388aa93af2c589a040773131b7 (diff)
Improves mat's cli behaviour on faulty options
`mat` will now show help message
-rwxr-xr-xmat14
1 files changed, 10 insertions, 4 deletions
diff --git a/mat b/mat
index 03a0ce1..e6faac4 100755
--- a/mat
+++ b/mat
@@ -11,8 +11,8 @@ from libmat import mat
11from libmat import archive 11from libmat import archive
12 12
13 13
14def parse(): 14def create_arg_parser():
15 """ Get, and parse options passed to the program 15 """ Get options passed to the program
16 """ 16 """
17 parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit') 17 parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit')
18 parser.add_argument('files', nargs='*') 18 parser.add_argument('files', nargs='*')
@@ -35,7 +35,7 @@ def parse():
35 info.add_argument('-v', '--version', action='version', 35 info.add_argument('-v', '--version', action='version',
36 version='MAT %s' % mat.__version__) 36 version='MAT %s' % mat.__version__)
37 37
38 return parser.parse_args() 38 return parser
39 39
40 40
41def list_meta(class_file, filename, add2archive): 41def list_meta(class_file, filename, add2archive):
@@ -114,7 +114,13 @@ def list_supported():
114 114
115def main(): 115def main():
116 """ Main function: get args and launch the appropriate function """ 116 """ Main function: get args and launch the appropriate function """
117 args = parse() 117 args = create_arg_parser()
118
119 if len(sys.argv) < 2: # show help when the there is no argument provided
120 args.print_help()
121 sys.exit(2)
122
123 args = args.parse_args()
118 124
119 # func receives the function corresponding to the options given as parameters 125 # func receives the function corresponding to the options given as parameters
120 if args.display: # only print metadatas 126 if args.display: # only print metadatas