Skip to content

Commit

Permalink
Added verbose argument to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
moses-palmer committed Sep 14, 2016
1 parent e22aa87 commit 8416916
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/truepy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def __call__(self, parser, namespace, value, option_string=None):
const=None,
action=PasswordAction)

parser.add_argument(
'--verbose',
help='Show a stack trace on error.',
action='store_true')

parser.add_argument(
'action',
help='The action to perform; this can be any of %s' % ', '.join(
Expand All @@ -236,10 +241,14 @@ def __call__(self, parser, namespace, value, option_string=None):
default=[])

try:
sys.exit(main(**vars(parser.parse_args())))
namespace = parser.parse_args()
sys.exit(main(**vars(namespace)))
except Exception as e:
try:
sys.stderr.write('%s\n' % e.args[0] % e.args[1:])
except:
sys.stderr.write('%s\n' % str(e))
if namespace and namespace.verbose:
import traceback
traceback.print_exc()
sys.exit(1)

0 comments on commit 8416916

Please sign in to comment.