Merge pull request #312 from rofl0r/help-fix2
fix help text when invoked with --help
This commit is contained in:
commit
d8524ac8d0
50
electrum
50
electrum
|
@ -66,7 +66,8 @@ def prompt_password(prompt, confirm=True):
|
||||||
|
|
||||||
def arg_parser():
|
def arg_parser():
|
||||||
usage = "%prog [options] command"
|
usage = "%prog [options] command"
|
||||||
parser = optparse.OptionParser(prog=usage)
|
parser = optparse.OptionParser(prog=usage, add_help_option = False)
|
||||||
|
parser.add_option("-h", "--help", action="callback", callback=print_help_cb, help="show this help text")
|
||||||
parser.add_option("-g", "--gui", dest="gui", help="User interface: qt, lite, gtk or text")
|
parser.add_option("-g", "--gui", dest="gui", help="User interface: qt, lite, gtk or text")
|
||||||
parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)")
|
parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)")
|
||||||
parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline")
|
parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline")
|
||||||
|
@ -85,6 +86,32 @@ def arg_parser():
|
||||||
parser.add_option("-G", "--gap", dest="gap_limit", default=None, help="gap limit")
|
parser.add_option("-G", "--gap", dest="gap_limit", default=None, help="gap limit")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def print_help(parser):
|
||||||
|
parser.print_help()
|
||||||
|
print_msg("Type 'electrum help <command>' to see the help for a specific command")
|
||||||
|
print_msg("Type 'electrum --help' to see the list of options")
|
||||||
|
run_command('help')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def print_help_cb(self, opt, value, parser):
|
||||||
|
print_help(parser)
|
||||||
|
|
||||||
|
def run_command(cmd, password = None, args = []):
|
||||||
|
cmd_runner = Commands(wallet, network)
|
||||||
|
func = eval('cmd_runner.' + cmd)
|
||||||
|
cmd_runner.password = password
|
||||||
|
try:
|
||||||
|
result = func(*args[1:])
|
||||||
|
except BaseException, e:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if type(result) == str:
|
||||||
|
util.print_msg(result)
|
||||||
|
elif result is not None:
|
||||||
|
util.print_json(result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
@ -278,10 +305,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
elif cmd == 'help':
|
elif cmd == 'help':
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
parser.print_help()
|
print_help(parser)
|
||||||
print_msg("Type 'electrum help <command>' to see the help for a specific command")
|
|
||||||
print_msg("Type 'electrum --help' to see the list of options")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,21 +378,7 @@ if __name__ == '__main__':
|
||||||
wallet.update_password(seed, password, new_password)
|
wallet.update_password(seed, password, new_password)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
cmd_runner = Commands(wallet, network)
|
run_command(cmd, password, args)
|
||||||
func = eval('cmd_runner.' + cmd)
|
|
||||||
cmd_runner.password = password
|
|
||||||
try:
|
|
||||||
result = func(*args[1:])
|
|
||||||
except BaseException, e:
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc(file=sys.stdout)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if type(result) == str:
|
|
||||||
util.print_msg(result)
|
|
||||||
elif result is not None:
|
|
||||||
util.print_json(result)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if cmd not in offline_commands and not options.offline:
|
if cmd not in offline_commands and not options.offline:
|
||||||
|
|
Loading…
Reference in New Issue