[Pkg-privacy-commits] [mat] 42/68: Improves mat's cli behaviour on faulty options
Sascha Steinbiss
sascha at steinbiss.name
Sun Jan 3 12:32:41 UTC 2016
This is an automated email from the git hooks/post-receive script.
sascha-guest pushed a commit to branch master
in repository mat.
commit aa32b3dd050017d5876a924dd8ffb038285dc465
Author: jvoisin <julien.voisin at dustri.org>
Date: Tue Dec 8 15:20:26 2015 +0100
Improves mat's cli behaviour on faulty options
`mat` will now show help message
---
mat | 14 ++++++++++----
1 file 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
from libmat import archive
-def parse():
- """ Get, and parse options passed to the program
+def create_arg_parser():
+ """ Get options passed to the program
"""
parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit')
parser.add_argument('files', nargs='*')
@@ -35,7 +35,7 @@ def parse():
info.add_argument('-v', '--version', action='version',
version='MAT %s' % mat.__version__)
- return parser.parse_args()
+ return parser
def list_meta(class_file, filename, add2archive):
@@ -114,7 +114,13 @@ def list_supported():
def main():
""" Main function: get args and launch the appropriate function """
- args = parse()
+ args = create_arg_parser()
+
+ if len(sys.argv) < 2: # show help when the there is no argument provided
+ args.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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/mat.git
More information about the Pkg-privacy-commits
mailing list