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,CAAC,gBAAgB,EAAE,CAC3E,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;uDAcyC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["#!/usr/bin/env node\n/* eslint-disable no-restricted-globals */\nimport {\n  cleanBitcoinRegtestCache,\n  installBitcoinRegtest,\n  parseBitcoinRegtestInstallCliOptions,\n  readBitcoinRegtestInstallOptionsFromPackageJson,\n} from '../install';\n\nasync function main(): Promise<void> {\n  const [command, ...args] = process.argv.slice(2);\n\n  if (command === '--help' || command === 'help') {\n    printHelp();\n    return;\n  }\n\n  if (command === 'cache' && args[0] === 'clean') {\n    await cleanBitcoinRegtestCache({\n      ...readBitcoinRegtestInstallOptionsFromPackageJson(),\n      ...parseBitcoinRegtestInstallCliOptions(args.slice(1)),\n    });\n    console.log('[bitcoin-regtest-up] cache cleaned');\n    return;\n  }\n\n  const installArgs = command === 'install' ? args : process.argv.slice(2);\n  const result = await installBitcoinRegtest({\n    ...readBitcoinRegtestInstallOptionsFromPackageJson(),\n    ...parseBitcoinRegtestInstallCliOptions(installArgs),\n  });\n\n  console.log(\n    `[bitcoin-regtest-up] Bitcoin Core ${\n      result.cacheHit ? 'found in cache' : 'installed'\n    }`,\n  );\n  console.log(\n    `[bitcoin-regtest-up] bitcoind installed at ${result.bitcoindBinary}`,\n  );\n  console.log(\n    `[bitcoin-regtest-up] bitcoin-cli installed at ${result.bitcoinCliBinary}`,\n  );\n}\n\nmain().catch((error) => {\n  console.error(error);\n  process.exit(1);\n});\n\nfunction printHelp(): void {\n  console.log(`Usage: bitcoin-regtest-up [install] [options]\n       bitcoin-regtest-up cache clean [options]\n\nCommands:\n  install      Install Bitcoin Core bitcoind and bitcoin-cli. Default command.\n  cache clean  Remove cached bitcoin-regtest-up artifacts.\n\nOptions:\n  --bin-directory <path>          Directory for executable wrappers.\n                                   Defaults to node_modules/.bin.\n  --cache-directory <path>        Cache directory. Defaults to .metamask/cache.\n  --bitcoin-core-url <url>        Bitcoin Core archive URL for the current platform.\n  --bitcoin-core-checksum <hash>  Expected Bitcoin Core SHA-256 checksum.\n  --platform <platform>           Override platform key, e.g. linux-x64.\n  --help                          Show this help text.`);\n}\n"]}