util.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import argparse
  2. async def arg_parser(client):
  3. parser = argparse.ArgumentParser(
  4. prog='drk',
  5. usage='%(prog)s [commands]',
  6. description="""DarkFi wallet command-line tool"""
  7. )
  8. parser.add_argument('-c', '--cashier', action='store_true', help='Create a cashier wallet')
  9. parser.add_argument('-w', '--wallet', action='store_true', help='Create a new wallet')
  10. parser.add_argument('-k', '--key', action='store_true', help='Test key')
  11. parser.add_argument('-i', '--info', action='store_true', help='Request info from daemon')
  12. parser.add_argument('-hi', '--hello', action='store_true', help='Test hello')
  13. parser.add_argument("-s", "--stop", action='store_true', help="Send a stop signal to the daemon")
  14. try:
  15. args = parser.parse_args()
  16. if args.key:
  17. print("Attemping to generate a create key pair...")
  18. await client.key_gen(client.payload)
  19. if args.wallet:
  20. print("Attemping to create a wallet...")
  21. await client.create_wallet(client.payload)
  22. if args.info:
  23. print("Info was entered")
  24. await client.get_info(client.payload)
  25. print("Requesting daemon info...")
  26. if args.stop:
  27. print("Stop was entered")
  28. await client.stop(client.payload)
  29. print("Sending a stop signal...")
  30. if args.hello:
  31. print("Hello was entered")
  32. await client.say_hello(client.payload)
  33. if args.cashier:
  34. print("Attempting to generate a cashier wallet...")
  35. await client.create_cashier_wallet(client.payload)
  36. except Exception:
  37. raise
  38. #subparser = parser.add_subparsers(help='All available commands', title="Commands", dest='cmd')
  39. #subparser.metavar = 'subcommands';
  40. #login = subparser.add_parser('login', help='wallet login')
  41. ##test = subparser.add_parser('test', help='test wallet functions')
  42. #new = subparser.add_parser('new', help='create something new')
  43. #new.add_argument('-w', '--wallet', action='store_true', help='Create a new wallet')
  44. #new.add_argument('-k', '--key', action='store_true', help='Create a new key')
  45. #new.add_argument('-c', '--cashier', action='store_true', help='Create a cashier wallet')
  46. #login.add_argument('-u', '--username', type=str, required=True)
  47. #login.add_argument('-p', '--password', type=str, required=True)
  48. ##test.add_argument('-k', '--key', dest='key', action='store_true', help='Test key')
  49. ##test.add_argument('-p', '--path', dest='path', action='store_true', help='Test path')
  50. ##test.add_argument('-pk', '--pkey', dest='pkey', action='store_true', help='Print test key')
  51. ##test.add_argument('-ck', '--ckey', dest='ckey', action='store_true', help='Cashier test key')
  52. ##test.add_argument('-w', '--wallet', dest='wallet', action='store_true', help='Create a new wallet')
  53. ##test.add_argument('-c', '--cashier', dest='cashier',action='store_true', help='Create a cashier wallet')
  54. #if args.path:
  55. # try:
  56. # print("Testing path...")
  57. # client.test_path(client.payload)
  58. # except Exception:
  59. # raise
  60. #if args.pkey:
  61. # try:
  62. # print("Attempting to print cashier key...")
  63. # client.cashkey(client.payload)
  64. # except Exception:
  65. # raise