_ipfs 27 KB

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