docs: def main(device_type):
      """Parse command-line arguments."""
      epilog = ('See https://github.com/romanz/trezor-agent/blob/master/'
                'doc/README-GPG.md for usage examples.')
      parser = argparse.ArgumentParser(epilog=epilog)
  
      agent_package = device_type.package_name()
      resources_map = {r.key: r for r in pkg_resources.require(agent_package)}
      resources = [resources_map[agent_package], resources_map['libagent']]
      versions = '\n'.join('{}={}'.format(r.key, r.version) for r in resources)
      parser.add_argument('--version', help='print the version info',
                          action='version', version=versions)
  
      subparsers = parser.add_subparsers(title='Action', dest='action')
      subparsers.required = True
  
      p = subparsers.add_parser('init',
                                help='initialize hardware-based GnuPG identity')
      p.add_argument('user_id')
      p.add_argument('-e', '--ecdsa-curve', default='nist256p1')
      p.add_argument('-t', '--time', type=int, default=int(time.time()))
      p.add_argument('-v', '--verbose', default=0, action='count')
      p.add_argument('-s', '--subkey', default=False, action='store_true')
  
      p.add_argument('--homedir', type=str, default=os.environ.get('GNUPGHOME'),
                     help='Customize GnuPG home directory for the new identity.')
  
      p.add_argument('--pin-entry-binary', type=str, default='pinentry',
                     help='Path to PIN entry UI helper.')
      p.add_argument('--passphrase-entry-binary', type=str, default='pinentry',
                     help='Path to passphrase entry UI helper.')
      p.add_argument('--cache-expiry-seconds', type=float, default=float('inf'),
                     help='Expire passphrase from cache after this duration.')
  
      p.set_defaults(func=run_init)
  
      p = subparsers.add_parser('unlock', help='unlock the hardware device')
      p.add_argument('-v', '--verbose', default=0, action='count')
      p.set_defaults(func=run_unlock)
  
      args = parser.parse_args()
      device_type.ui = device.ui.UI(device_type=device_type, config=vars(args))
      device_type.ui.cached_passphrase_ack = util.ExpiringCache(
          seconds=float(args.cache_expiry_seconds))
  
      return args.func(device_type=device_type, args=args)