_ipfs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. #compdef ipfs
  2. #autoload
  3. local -a _1st_arguments
  4. _1st_arguments=(
  5. 'add:Add a file or directory to ipfs.'
  6. 'bitswap:Interact with the bitswap agent.'
  7. 'block:Interact with raw IPFS blocks.'
  8. 'bootstrap:Show or edit the list of bootstrap peers.'
  9. 'cat:Show IPFS object data.'
  10. 'cid:Convert and discover properties of CIDs'
  11. 'commands:List all available commands.'
  12. 'config:Get and set ipfs config values.'
  13. 'daemon:Run a network-connected IPFS node.'
  14. 'dag:Interact with ipld dag objects. (experimental)'
  15. 'dht:Issue commands directly through the DHT.'
  16. 'diag:Generate diagnostic reports.'
  17. 'dns:Resolve DNS links.'
  18. 'files:Interact with unixfs files.'
  19. 'filestore:Interact with filestore objects. (experimental)'
  20. 'get:Download IPFS objects.'
  21. 'id:Show ipfs node id info.'
  22. 'init:Initializes ipfs config file.'
  23. 'key:Create and list IPNS name keypairs.'
  24. 'log:Interact with the daemon log output.'
  25. 'ls:List directory contents for Unix filesystem objects.'
  26. 'mount:Mounts IPFS to the filesystem (read-only).'
  27. 'name:Publish and resolve IPNS names.'
  28. 'object:Interact with IPFS objects.'
  29. 'p2p:Libp2p stream mounting.'
  30. 'pin:Pin (and unpin) objects to local storage.'
  31. 'ping:Send echo request packets to IPFS hosts.'
  32. 'refs:List links (references) from an object.'
  33. 'repo:Manipulate the IPFS repo.'
  34. 'resolve:Resolve the value of names to IPFS.'
  35. 'stats:Query IPFS statistics.'
  36. 'swarm:Interact with the swarm.'
  37. 'tar:Utility functions for tar files in ipfs.'
  38. 'update:Download and apply go-ipfs updates'
  39. 'version:Show ipfs version information.'
  40. )
  41. _ipfs_subcommand(){
  42. local curcontext="$curcontext" state line
  43. typeset -A opt_args
  44. _arguments -C ':command:->command' '*::options:->options'
  45. case $state in
  46. (command)
  47. _describe -t commands "ipfs subcommand" $1
  48. return
  49. ;;
  50. (options)
  51. case $line[1] in
  52. (wantlist)
  53. case $MAIN_SUBCOMMAND in
  54. (bitswap)
  55. _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]'
  56. ;;
  57. esac
  58. ;;
  59. (add)
  60. case $MAIN_SUBCOMMAND in
  61. (pin)
  62. _arguments \
  63. '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \
  64. '--progress[Show progress.]'
  65. ;;
  66. (bootstrap)
  67. local -a _bootstrap_rm_arguments
  68. _bootstrap_rm_arguments=(
  69. 'default:Add default peers to the bootstrap list.'
  70. )
  71. _ipfs_subcommand _bootstrap_rm_arguments
  72. ;;
  73. esac
  74. ;;
  75. (rm)
  76. case $MAIN_SUBCOMMAND in
  77. (pin)
  78. _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]'
  79. ;;
  80. (bootstrap)
  81. local -a _bootstrap_rm_arguments
  82. _bootstrap_rm_arguments=(
  83. 'all:Remove all peers from the bootstrap list.'
  84. )
  85. _ipfs_subcommand _bootstrap_rm_arguments
  86. ;;
  87. esac
  88. ;;
  89. (ls)
  90. case $MAIN_SUBCOMMAND in
  91. (pin)
  92. _arguments \
  93. '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \
  94. '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]' \
  95. '(-s --stream)'{-s,--stream}'[Enable streaming of pins as they are discovered.]'
  96. ;;
  97. (p2p)
  98. _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]'
  99. ;;
  100. esac
  101. ;;
  102. (update)
  103. case $MAIN_SUBCOMMAND in
  104. (pin)
  105. _arguments '--unpin[Remove the old pin. Default: true.]'
  106. ;;
  107. esac
  108. ;;
  109. (verify)
  110. case $MAIN_SUBCOMMAND in
  111. (pin)
  112. _arguments \
  113. '--verbose[Also write the hashes of non-broken pins.]' \
  114. '(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]'
  115. ;;
  116. esac
  117. ;;
  118. (query|findpeer)
  119. case $MAIN_SUBCOMMAND in
  120. (dht)
  121. _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
  122. ;;
  123. esac
  124. ;;
  125. (get)
  126. case $MAIN_SUBCOMMAND in
  127. (dht)
  128. _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
  129. ;;
  130. (object)
  131. _arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]'
  132. ;;
  133. esac
  134. ;;
  135. (put)
  136. case $MAIN_SUBCOMMAND in
  137. (dht)
  138. _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
  139. ;;
  140. (object)
  141. _arguments \
  142. '--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \
  143. '--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \
  144. '--pin[Pin this object when adding.]' \
  145. '(-q --quiet)'{-q,--quiet}'[Write minimal output]'
  146. ;;
  147. esac
  148. ;;
  149. (findprovs)
  150. case $MAIN_SUBCOMMAND in
  151. (dht)
  152. _arguments \
  153. '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
  154. '(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]'
  155. ;;
  156. esac
  157. ;;
  158. (provide)
  159. case $MAIN_SUBCOMMAND in
  160. (dht)
  161. _arguments \
  162. '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
  163. '(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]'
  164. ;;
  165. esac
  166. ;;
  167. (cmds)
  168. case $MAIN_SUBCOMMAND in
  169. (diag)
  170. _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
  171. ;;
  172. esac
  173. ;;
  174. (diff)
  175. case $MAIN_SUBCOMMAND in
  176. (object)
  177. _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
  178. ;;
  179. esac
  180. ;;
  181. (stat)
  182. case $MAIN_SUBCOMMAND in
  183. (dag)
  184. _arguments \
  185. '(-p --progress)'{-p,--progress}'[Return progressive data while reading through the DAG. Default: true.]'
  186. ;;
  187. (object)
  188. _arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
  189. ;;
  190. (repo)
  191. _arguments \
  192. '(-s --size-only)'{-s,--size-only}'[Only report RepoSize and StorageMax.]' \
  193. '(-H --human)'{-H,--human}'[Print sizes in human readable format (e.g., 1K 234M 2G).]'
  194. ;;
  195. esac
  196. ;;
  197. (publish)
  198. case $MAIN_SUBCOMMAND in
  199. (name)
  200. _arguments \
  201. '--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
  202. '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
  203. '--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
  204. '--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
  205. '(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
  206. '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
  207. '--ipns-base[Encoding used for keys: Can either be a multibase encoded CID or a base58btc encoded multihash. Takes {b58mh|base36|k|base32|b...}. Default: base36.]'
  208. ;;
  209. esac
  210. ;;
  211. (pubsub)
  212. case $MAIN_SUBCOMMAND in
  213. (name)
  214. local -a _name_pubsub_arguments
  215. _name_pubsub_arguments=(
  216. 'cancel:Cancel a name subscription'
  217. 'state:Query the state of IPNS pubsub'
  218. 'subs:Show current name subscriptions'
  219. )
  220. _ipfs_subcommand _name_pubsub_arguments
  221. ;;
  222. esac
  223. ;;
  224. (resolve)
  225. case $MAIN_SUBCOMMAND in
  226. (name)
  227. _arguments \
  228. '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \
  229. '(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \
  230. '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
  231. '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \
  232. '(-s --stream)'{-s,--stream}'[Stream entries as they are found.]'
  233. ;;
  234. esac
  235. ;;
  236. (patch)
  237. case $MAIN_SUBCOMMAND in
  238. (object)
  239. local -a _object_patch_arguments
  240. _object_patch_arguments=(
  241. 'add-link:Add a link to a given object.'
  242. 'append-data:Append data to the data segment of a dag node.'
  243. 'rm-link:Remove a link from a given object.'
  244. 'set-data:Set the data field of an IPFS object.'
  245. )
  246. _ipfs_subcommand _object_patch_arguments
  247. ;;
  248. esac
  249. ;;
  250. (gc)
  251. case $MAIN_SUBCOMMAND in
  252. (repo)
  253. _arguments \
  254. '--stream-errors[Stream errors.]' \
  255. '(-q --quiet)'{-q,--quiet}'[Write minimal output.]'
  256. ;;
  257. esac
  258. ;;
  259. (bitswap)
  260. case $MAIN_SUBCOMMAND in
  261. (stats)
  262. _arguments \
  263. '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
  264. '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
  265. ;;
  266. esac
  267. ;;
  268. (bw)
  269. case $MAIN_SUBCOMMAND in
  270. (stats)
  271. _arguments \
  272. '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \
  273. '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \
  274. '--poll[Print bandwidth at an interval.]' \
  275. '(-i --interval)'{-i,--interval}"[Time interval to wait between updating output, if 'poll' is true.]"
  276. ;;
  277. esac
  278. ;;
  279. (repo)
  280. case $MAIN_SUBCOMMAND in
  281. (stats)
  282. _arguments \
  283. '--size-only[Only report RepoSize and StorageMax.]' \
  284. '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
  285. ;;
  286. esac
  287. ;;
  288. (bases)
  289. case $MAIN_SUBCOMMAND in
  290. (cid)
  291. _arguments \
  292. '--prefix[also include the single leter prefixes in addition to the code.]' \
  293. '--numeric[also include numeric codes.]'
  294. ;;
  295. esac
  296. ;;
  297. (codecs|hashes)
  298. case $MAIN_SUBCOMMAND in
  299. (cid)
  300. _arguments '--numeric[also include numeric codes.]'
  301. ;;
  302. esac
  303. ;;
  304. (format)
  305. case $MAIN_SUBCOMMAND in
  306. (cid)
  307. _arguments \
  308. '-f[Printf style format string. Default: %s.]' \
  309. '-v[CID version to convert to.]' \
  310. '--codec[CID codec to convert to.]' \
  311. '-b[Multibase to display CID in.]'
  312. ;;
  313. esac
  314. ;;
  315. (close)
  316. case $MAIN_SUBCOMMAND in
  317. (p2p)
  318. _arguments \
  319. '(-a --all)'{-a,--all}'[Close all listeners.]' \
  320. '(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \
  321. '(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \
  322. '(-t --target-address)'{-t,--target-address}'[Match target address.]'
  323. ;;
  324. esac
  325. ;;
  326. (forward)
  327. case $MAIN_SUBCOMMAND in
  328. (p2p)
  329. _arguments "--allow-custom-protocol[Don't require /x/ prefix.]"
  330. ;;
  331. esac
  332. ;;
  333. (listen)
  334. case $MAIN_SUBCOMMAND in
  335. (p2p)
  336. _arguments \
  337. "--allow-custom-protocol[Don't require /x/ prefix.]" \
  338. '(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]'
  339. ;;
  340. esac
  341. ;;
  342. (stream)
  343. case $MAIN_SUBCOMMAND in
  344. (p2p)
  345. local -a _p2p_stream_arguments
  346. _p2p_stream_arguments=(
  347. 'close:Close active p2p stream.'
  348. 'ls:List active p2p streams.'
  349. )
  350. _ipfs_subcommand _p2p_stream_arguments
  351. ;;
  352. esac
  353. ;;
  354. (addrs)
  355. case $MAIN_SUBCOMMAND in
  356. (swarm)
  357. local -a _swarm_addrs_arguments
  358. _swarm_addrs_arguments=(
  359. 'listen:List interface listening addresses.'
  360. 'local:List local addresses.'
  361. )
  362. _ipfs_subcommand _swarm_addrs_arguments
  363. ;;
  364. esac
  365. ;;
  366. (filters)
  367. case $MAIN_SUBCOMMAND in
  368. (swarm)
  369. local -a _swarm_filters_arguments
  370. _swarm_filters_arguments=(
  371. 'add:Add an address filter.'
  372. 'rm:Remove an address filter.'
  373. )
  374. _ipfs_subcommand _swarm_filters_arguments
  375. ;;
  376. esac
  377. ;;
  378. (peers)
  379. case $MAIN_SUBCOMMAND in
  380. (swarm)
  381. _arguments \
  382. '(-v --verbose)'{-v,--verbose}'[display all extra information.]' \
  383. '--streams[Also list information about open streams for each peer.]' \
  384. '--latency[Also list information about latency to each peer.]' \
  385. '--direction[Also list information about the direction of connection.]'
  386. ;;
  387. esac
  388. ;;
  389. (export)
  390. case $MAIN_SUBCOMMAND in
  391. (dag)
  392. _arguments \
  393. '(-p --progress)'{-p,--progress}'[Display progress on CLI. Defaults to true when STDERR is a TTY.]'
  394. ;;
  395. (key)
  396. _arguments \
  397. '(-o --output)'{-o,--output}'[The path where the output should be stored.]'
  398. ;;
  399. esac
  400. ;;
  401. (import)
  402. case $MAIN_SUBCOMMAND in
  403. (dag)
  404. _arguments \
  405. '--silent[No output.]' \
  406. '--pin-roots[Pin optional roots listed in the .car headers after importing. Default: true.]'
  407. ;;
  408. (key)
  409. _arguments \
  410. '--ipns-base[Encoding used for keys: Can either be a multibase encoded CID or a base58btc encoded multihash. Takes {b58mh|base36|k|base32|b...}. Default: base36.]'
  411. ;;
  412. esac
  413. ;;
  414. (remote)
  415. case $MAIN_SUBCOMMAND in
  416. (pin)
  417. local -a _pin_remote_arguments
  418. _pin_remote_arguments=(
  419. 'add:Pin object to remote pinning service.'
  420. 'ls:List objects pinned to remote pinning service.'
  421. 'rm:Remove pins from remote pinning service.'
  422. 'service:Configure remote pinning services.'
  423. )
  424. _ipfs_subcommand _pin_remote_arguments
  425. ;;
  426. esac
  427. ;;
  428. esac
  429. ;;
  430. esac
  431. }
  432. local expl
  433. _arguments \
  434. '(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \
  435. '(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \
  436. '(--help)--help[Show the full command help text.]' \
  437. '(--h)-h[Show a short version of the command help text.]' \
  438. '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \
  439. '(--offline)--offline[Run the command offline.]' \
  440. '(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \
  441. '(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \
  442. '(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \
  443. '(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \
  444. '(--stream-channels)--stream-channels[Stream channel output.]' \
  445. '(--timeout)--timeout[Set a global timeout on the command.]' \
  446. '*:: :->subcmds' && return 0
  447. if (( CURRENT == 1 )); then
  448. _describe -t commands "ipfs subcommand" _1st_arguments
  449. return
  450. fi
  451. MAIN_SUBCOMMAND="$words[1]"
  452. case $MAIN_SUBCOMMAND in
  453. (add)
  454. _arguments \
  455. '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \
  456. '(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \
  457. '(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \
  458. '(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \
  459. '(--ignore)--ignore[A rule (.gitignore-stype) defining which file(s) should be ignored (variadic, experimental).]' \
  460. '(--ignore-rules-path)--ignore-rules-path[A path to a file with .gitignore-style ignore rules (experimental).]' \
  461. '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \
  462. '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
  463. '(--silent)--silent[Write no output.]' \
  464. '(-p --progress)'{-p,--progress}'[Stream progress data.]' \
  465. '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \
  466. '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \
  467. '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \
  468. '(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \
  469. '(--pin)--pin[Pin this object when adding. Default: true.]' \
  470. '(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \
  471. '(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \
  472. '(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \
  473. '(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \
  474. '(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \
  475. '(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \
  476. '(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]'
  477. ;;
  478. (bitswap)
  479. local -a _bitswap_arguments
  480. _bitswap_arguments=(
  481. 'ledger:Show the current ledger for a peer.'
  482. 'reprovide:Trigger reprovider.'
  483. 'stat:Show some diagnostic information on the bitswap agent.'
  484. 'wantlist:Show blocks currently on the wantlist.'
  485. )
  486. _ipfs_subcommand _bitswap_arguments
  487. ;;
  488. (block)
  489. local -a _block_arguments
  490. _block_arguments=(
  491. 'get:Get a raw IPFS block.'
  492. 'put:Store input as an IPFS block.'
  493. 'rm:Remove IPFS block(s).'
  494. 'stat:Print information of a raw IPFS block.'
  495. )
  496. _ipfs_subcommand _block_arguments
  497. ;;
  498. (bootstrap)
  499. local -a _bootstrap_arguments
  500. _bootstrap_arguments=(
  501. 'add:Add peers to the bootstrap list.'
  502. 'list:Show peers in the bootstrap list.'
  503. 'rm:Remove peers from the bootstrap list.'
  504. )
  505. _ipfs_subcommand _bootstrap_arguments
  506. ;;
  507. (cat)
  508. _arguments \
  509. '(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \
  510. '(-l --length)'{-l,--length}'[Maximum number of bytes to read.]'
  511. ;;
  512. (cid)
  513. local -a _cid_arguments
  514. _cid_arguments=(
  515. 'base32:Convert CIDs to Base32 CID version 1.'
  516. 'bases:List available multibase encodings.'
  517. 'codecs:List available CID codecs.'
  518. 'format:Format and convert a CID in various useful ways.'
  519. 'hashes:List available multihashes.'
  520. )
  521. _ipfs_subcommand _cid_arguments
  522. ;;
  523. (commands)
  524. _arguments '(-f --flags)'{-f,--flags}'[Show command flags.]'
  525. ;;
  526. (config)
  527. _arguments \
  528. '--bool[Set a boolean value.]' \
  529. '--json[Parse stringified JSON.]'
  530. local -a _config_arguments
  531. _config_arguments=(
  532. 'edit:Open the config file for editing in $EDITOR.'
  533. 'profile:Apply profiles to config.'
  534. 'replace:Replace the config with <file>.'
  535. 'show:Output config file contents.'
  536. )
  537. _ipfs_subcommand _config_arguments
  538. ;;
  539. (daemon)
  540. _arguments \
  541. '--init[Initialize ipfs with default settings if not already initialized.]' \
  542. '--init-config[Path to existing configuration file to be loaded during --init.]' \
  543. '--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \
  544. '--routing[Overrides the routing option. Default: default.]' \
  545. '--mount[Mounts IPFS to the filesystem.]' \
  546. '--writable[Enable writing objects (with POST, PUT and DELETE).]' \
  547. '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \
  548. '--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \
  549. '--unrestricted-api[Allow API access to unlisted hashes.]' \
  550. '--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \
  551. '--enable-gc[Enable automatic periodic repo garbage collection.]' \
  552. '--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \
  553. '--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \
  554. '--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \
  555. '--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \
  556. '--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]'
  557. ;;
  558. (dag)
  559. local -a _dag_arguments
  560. _dag_arguments=(
  561. 'export:Streams the selected DAG as a .car stream on stdout.'
  562. 'get:Get a dag node from ipfs.'
  563. 'import:Import the contents of .car files'
  564. 'put:Add a dag node to ipfs.'
  565. 'resolve:Resolve ipld block.'
  566. 'stat:Gets stats for a DAG'
  567. )
  568. _ipfs_subcommand _dag_arguments
  569. ;;
  570. (dht)
  571. local -a _dht_arguments
  572. _dht_arguments=(
  573. 'findpeer:Find the multiaddresses associated with a Peer ID.'
  574. 'findprovs:Find peers that can provide a specific value, given a key.'
  575. 'get:Given a key, query the routing system for its best value.'
  576. 'provide:Announce to the network that you are providing given values.'
  577. 'put:Write a key/value pair to the routing system.'
  578. 'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.'
  579. )
  580. _ipfs_subcommand _dht_arguments
  581. ;;
  582. (diag)
  583. local -a _diag_arguments
  584. _diag_arguments=(
  585. 'cmds:List commands run on this IPFS node.'
  586. 'sys:Print system diagnostic information.'
  587. )
  588. _ipfs_subcommand _diag_arguments
  589. ;;
  590. (dns)
  591. _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]'
  592. ;;
  593. (files)
  594. _arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]'
  595. local -a _files_arguments
  596. _files_arguments=(
  597. 'chcid:Change the cid version or hash function of the root node of a given path.'
  598. 'cp:Copy files into mfs.'
  599. "flush:Flush a given path's data to disk."
  600. 'ls:List directories in the local mutable namespace.'
  601. 'mkdir:Make directories.'
  602. 'mv:Move files.'
  603. 'read:Read a file in a given mfs.'
  604. 'rm:Remove a file.'
  605. 'stat:Display file status.'
  606. 'write:Write to a mutable file in a given filesystem.'
  607. )
  608. _ipfs_subcommand _files_arguments
  609. ;;
  610. (filestore)
  611. local -a _filestore_arguments
  612. _filestore_arguments=(
  613. 'dups:List blocks that are both in the filestore and standard block storage.'
  614. 'ls:List objects in filestore.'
  615. 'verify:Verify objects in filestore.'
  616. )
  617. _ipfs_subcommand _filestore_arguments
  618. ;;
  619. (get)
  620. _arguments \
  621. '(-o --output)'{-o,--output}'[The path where the output should be stored.]'\
  622. '(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \
  623. '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \
  624. '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]'
  625. ;;
  626. (id)
  627. _arguments \
  628. '(-f --format)'{-f,--format}'[Optional output format.]' \
  629. '--peerid-base[Encoding used for peer IDs: Can either be a multibase encoded CID or a base58btc encoded multihash. Takes {b58mh|base36|k|base32|b...}. Default: b58mh.]'
  630. ;;
  631. (init)
  632. _arguments \
  633. '(-a --algorithm)'{-a, --algorithm}'[Cryptographic algorithm to use for key generation. Default: ed25519.]' \
  634. '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key.]' \
  635. '(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \
  636. '(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]"
  637. ;;
  638. (key)
  639. local -a _key_arguments
  640. _key_arguments=(
  641. 'export:Export a keypair'
  642. 'gen:Create a new keypair'
  643. 'import:Import a key and prints imported key id'
  644. 'list:List all local keypairs'
  645. 'rename:Rename a keypair'
  646. 'rm:Remove a keypair'
  647. 'rotate:Rotates the ipfs identity.'
  648. )
  649. _ipfs_subcommand _key_arguments
  650. ;;
  651. (log)
  652. local -a _log_arguments
  653. _log_arguments=(
  654. 'level:Change the logging level.'
  655. 'ls:List the logging subsystems.'
  656. 'tail:Read the event log.'
  657. )
  658. _ipfs_subcommand _log_arguments
  659. ;;
  660. (ls)
  661. _arguments \
  662. '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \
  663. '--resolve-type[Resolve linked objects to find out their types. Default: true.]' \
  664. '--size[Resolve linked objects to find out their file size. Default: true.]' \
  665. '(-s --stream)'{-s,--stream}'[Enable experimental streaming of directory entries as they are traversed.]' \
  666. ;;
  667. (mount)
  668. _arguments \
  669. '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \
  670. '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]'
  671. ;;
  672. (name)
  673. local -a _name_arguments
  674. _name_arguments=(
  675. 'publish:Publish IPNS names.'
  676. 'pubsub:IPNS pubsub management.'
  677. 'resolve:Resolve IPNS names.'
  678. )
  679. _ipfs_subcommand _name_arguments
  680. ;;
  681. (object)
  682. local -a _object_arguments
  683. _object_arguments=(
  684. 'data:Output the raw bytes of an IPFS object.'
  685. 'diff:Display the diff between two ipfs objects.'
  686. 'get:Get and serialize the DAG node named by <key>.'
  687. 'links:Output the links pointed to by the specified object.'
  688. 'new:Create a new object from an ipfs template.'
  689. 'patch:Create a new merkledag object based on an existing one.'
  690. 'put:Store input as a DAG object, print its key.'
  691. 'stat:Get stats for the DAG node named by <key>.'
  692. )
  693. _ipfs_subcommand _object_arguments
  694. ;;
  695. (p2p)
  696. local -a _p2p_arguments
  697. _p2p_arguments=(
  698. 'close:Stop listening for new connections to forward.'
  699. 'forward:Forward connections to libp2p service'
  700. 'listen:Create libp2p service'
  701. 'ls:List active p2p listeners.'
  702. 'stream:P2P stream management.'
  703. )
  704. _ipfs_subcommand _p2p_arguments
  705. ;;
  706. (pin)
  707. local -a _pin_arguments
  708. _pin_arguments=(
  709. 'add:Pin objects to local storage.'
  710. 'ls:List objects pinned to local storage.'
  711. 'remote:Pin (and unpin) objects to remote pinning service.'
  712. 'rm:Remove pinned objects from local storage.'
  713. 'update:Update a recursive pin'
  714. 'verify:Verify that recursive pins are complete.'
  715. )
  716. _ipfs_subcommand _pin_arguments
  717. ;;
  718. (ping)
  719. _arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]'
  720. ;;
  721. (refs)
  722. _arguments \
  723. '--format[Emit edges with given format. Available tokens: <src> <dst> <linkname>. Default: <dst>.]' \
  724. '(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`.]' \
  725. '(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \
  726. '(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \
  727. '--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]'
  728. local -a _refs_arguments
  729. _refs_arguments='local:List all local references.'
  730. _ipfs_subcommand _refs_arguments
  731. ;;
  732. (repo)
  733. local -a _repo_arguments
  734. _repo_arguments=(
  735. 'fsck:Remove repo lockfiles.'
  736. 'gc:Perform a garbage collection sweep on the repo.'
  737. 'stat:Get stats for the currently used repo.'
  738. 'verify:Verify all blocks in repo are not corrupted.'
  739. 'version:Show the repo version.'
  740. )
  741. _ipfs_subcommand _repo_arguments
  742. ;;
  743. (resolve)
  744. _arguments \
  745. '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \
  746. '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
  747. '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]'
  748. ;;
  749. (stats)
  750. local -a _stats_arguments
  751. _stats_arguments=(
  752. 'bitswap:Show some diagnostic information on the bitswap agent.'
  753. 'bw:Print ipfs bandwidth information.'
  754. "dht:Returns statistics about the node's DHT(s)"
  755. 'repo:Get stats for the currently used repo.'
  756. )
  757. _ipfs_subcommand _stats_arguments
  758. ;;
  759. (swarm)
  760. local -a _swarm_arguments
  761. _swarm_arguments=(
  762. 'addrs:List known addresses. Useful for debugging.'
  763. 'connect:Open connection to a given address.'
  764. 'disconnect:Close connection to a given address.'
  765. 'filters:Manipulate address filters.'
  766. 'peers:List peers with open connections.'
  767. )
  768. _ipfs_subcommand _swarm_arguments
  769. ;;
  770. (tar)
  771. local -a _tar_arguments
  772. _tar_arguments=(
  773. 'add:Import a tar file into ipfs.'
  774. 'cat:Export a tar file from IPFS.'
  775. )
  776. _ipfs_subcommand _tar_arguments
  777. ;;
  778. (version)
  779. _arguments \
  780. '(-n --number)'{-n,--number}'[Only show the version number.]' \
  781. '--commit[Show the commit hash.]' \
  782. '--repo[Show repo version.]' \
  783. '--all[Show all version information.]'
  784. ;;
  785. esac