URI: 
       tMerge pull request #312 from rofl0r/help-fix2 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit d8524ac8d0481f71e46d64b06f6b10ce5414e4f7
   DIR parent c6de3a429df21217f508fda567a7e4f5f174f3da
  HTML Author: ThomasV <thomasv1@gmx.de>
       Date:   Thu, 19 Sep 2013 01:41:23 -0700
       
       Merge pull request #312 from rofl0r/help-fix2
       
       fix help text when invoked with --help
       Diffstat:
         M electrum                            |      50 +++++++++++++++++++-------------
       
       1 file changed, 30 insertions(+), 20 deletions(-)
       ---
   DIR diff --git a/electrum b/electrum
       t@@ -66,7 +66,8 @@ def prompt_password(prompt, confirm=True):
        
        def arg_parser():
            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("-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")
       t@@ -85,6 +86,32 @@ def arg_parser():
            parser.add_option("-G", "--gap", dest="gap_limit", default=None, help="gap limit")
            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__':
        
       t@@ -278,10 +305,7 @@ if __name__ == '__main__':
        
            elif cmd == 'help':
                if len(args) < 2:
       -            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")
       -
       +            print_help(parser)
        
                        
        
       t@@ -354,21 +378,7 @@ if __name__ == '__main__':
                wallet.update_password(seed, password, new_password)
        
            else:
       -        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)
       -            
       +        run_command(cmd, password, args)
                
        
            if cmd not in offline_commands and not options.offline: