[projects/git-slug: 160/170] Print help message when no subcommand is provided
glen
glen at pld-linux.org
Mon Sep 21 21:52:15 CEST 2015
commit 566f7710174f9c23d52e64f0e86d7cb9a540bcbd
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Mon Jan 21 03:42:45 2013 +0000
Print help message when no subcommand is provided
It seems there was change in behaviour of argparse in python3.3:
http://bugs.python.org/issue16308
So now we have to print the error message explicitly when no
subcommand is provided by user.
slug.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/slug.py b/slug.py
index c13e830..69bd3b9 100755
--- a/slug.py
+++ b/slug.py
@@ -275,7 +275,9 @@ listpkgs.set_defaults(func=list_packages)
default_options['list'] = {}
options = parser.parse_args()
-for key in default_options[options.command]:
- setattr(options, key, default_options[options.command][key])
-
-options.func(options)
+if hasattr(options, "func"):
+ for key in default_options[options.command]:
+ setattr(options, key, default_options[options.command][key])
+ options.func(options)
+else:
+ parser.print_help()
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list