mmgen-tool 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env python
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. mmgen-tool: Perform various Bitcoin-related operations - part of the MMGen suite
  20. """
  21. import sys
  22. import mmgen.config as g
  23. import mmgen.tool as tool
  24. from mmgen.Opts import *
  25. help_data = {
  26. 'prog_name': g.prog_name,
  27. 'desc': "Perform various BTC-related operations",
  28. 'usage': "[opts] <command> <command args>",
  29. 'options': """
  30. -d, --outdir= d Specify an alternate directory 'd' for output
  31. -h, --help Print this help message
  32. -q, --quiet Produce quieter output
  33. -r, --usr-randchars=n Get 'n' characters of additional randomness from
  34. user (min={g.min_urandchars}, max={g.max_urandchars})
  35. -v, --verbose Produce more verbose output
  36. """.format(g=g),
  37. 'notes': """
  38. COMMANDS:{}
  39. Type '{} <command> --help for usage information on a particular
  40. command
  41. """.format(tool.command_help,g.prog_name)
  42. }
  43. opts,cmd_args = parse_opts(sys.argv,help_data)
  44. if 'quiet' in opts: g.quiet = True
  45. if 'verbose' in opts: g.verbose = True
  46. if len(cmd_args) < 1:
  47. usage(help_data)
  48. sys.exit(1)
  49. command = cmd_args.pop(0)
  50. if command not in tool.commands.keys():
  51. msg("'%s': No such command" % command)
  52. sys.exit(1)
  53. if cmd_args and cmd_args[0] == '--help':
  54. tool.tool_usage(g.prog_name, command)
  55. sys.exit(0)
  56. args = tool.process_args(g.prog_name, command, cmd_args)
  57. tool.opts = opts
  58. #print command + "(" + ", ".join(args) + ")"
  59. eval("tool." + command + "(" + ", ".join(args) + ")")