From 7983af23b795eecea729791a113fc7a0565d3e51 Mon Sep 17 00:00:00 2001 From: Muri Nicanor Date: Wed, 9 Dec 2015 21:43:39 +0100 Subject: refined argument exceptions --- mat | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mat b/mat index a9ef9a0..4b6624e 100755 --- a/mat +++ b/mat @@ -114,14 +114,15 @@ def list_supported(): def main(): """ Main function: get args and launch the appropriate function """ - args = create_arg_parser() + argparser = create_arg_parser() + args = argparser.parse_args() - if len(sys.argv) < 2: # show help when the there is no argument provided - args.print_help() + #show help if: neiter list nor file argument given; no argument at + #all given or the list argument mixed with some other argument given + if (not args.list and not args.files) or (not len(sys.argv) > 1) or (args.list and len(sys.argv) > 2): + argparser.print_help() sys.exit(2) - args = args.parse_args() - # func receives the function corresponding to the options given as parameters if args.display: # only print metadatas func = list_meta -- cgit v1.3