forked from LBRYCommunity/lbry-sdk
Merge pull request #546 from lbryio/fix_cli_error_msg
format help message properly in case of error in CLI
This commit is contained in:
commit
3d606b95aa
1 changed files with 5 additions and 3 deletions
|
@ -64,8 +64,7 @@ def main():
|
||||||
os.path.basename(sys.argv[0]))
|
os.path.basename(sys.argv[0]))
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
help_response = api.call('help', params)
|
print_help_response(api.call('help', params))
|
||||||
print help_response['help'] if 'help' in help_response else help_response
|
|
||||||
|
|
||||||
elif method not in api.commands():
|
elif method not in api.commands():
|
||||||
print_error("'" + method + "' is not a valid command.")
|
print_error("'" + method + "' is not a valid command.")
|
||||||
|
@ -84,13 +83,16 @@ def main():
|
||||||
# instead of this generic message.
|
# instead of this generic message.
|
||||||
# https://app.asana.com/0/158602294500137/200173944358192
|
# https://app.asana.com/0/158602294500137/200173944358192
|
||||||
print "Something went wrong, here's the usage for %s:" % method
|
print "Something went wrong, here's the usage for %s:" % method
|
||||||
print api.call('help', {'command': method})
|
print_help_response(api.call('help', {'command': method}))
|
||||||
if hasattr(err, 'msg'):
|
if hasattr(err, 'msg'):
|
||||||
print "Here's the traceback for the error you encountered:"
|
print "Here's the traceback for the error you encountered:"
|
||||||
print err.msg
|
print err.msg
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def print_help_response(help_response):
|
||||||
|
print help_response['help'] if 'help' in help_response else help_response
|
||||||
|
|
||||||
def guess_type(x):
|
def guess_type(x):
|
||||||
if '.' in x:
|
if '.' in x:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue