#compdef ipfs #autoload local -a _1st_arguments _1st_arguments=( 'add: Add an object to ipfs.' 'bitswap:A set of commands to manipulate the bitswap agent' 'block:Manipulate raw IPFS blocks' 'bootstrap:Show or edit the list of bootstrap peers' 'cat: Show IPFS object data' 'commands:List all available commands.' 'config: [] get and set IPFS config values' 'daemon:Run a network-connected IPFS node' 'dht:Issue commands directly through the DHT' 'diag:Generates diagnostic reports' 'dns: DNS link resolver' 'file:Interact with ipfs objects representing Unix filesystems' 'get:Download IPFS objects' 'id:[] Show IPFS Node ID info' 'init:Initializes IPFS config file' 'log:Interact with the daemon log output' 'ls: List links from an object.' 'mount:Mounts IPFS to the filesystem (read-only)' 'name:IPFS namespace (IPNS) tool' 'object:Interact with ipfs objects' 'pin:Pin (and unpin) objects to local storage' 'ping: Send echo request packets to IPFS hosts' 'refs: Lists links (references) from an object' 'repo:Manipulate the IPFS repo' 'resolve:Resolve the value of names to IPFS' 'stats:Query IPFS statistics' 'swarm:Swarm inspection tool' 'tar:Utility functions for tar files in ipfs' 'tour:[] An introduction to IPFS' 'update:Downloads and installs updates for IPFS (disabled)' 'version:Shows ipfs version information' ) _ipfs_subcommand(){ local curcontext="$curcontext" state line typeset -A opt_args _arguments -C \ ':command:->command' \ '*::options:->options' case $state in (command) _describe -t commands "ipfs subcommand" $1 return ;; (options) case $line[1] in (wantlist) case $MAIN_SUBCOMMAND in (bitswap) _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for (default self)]' ;; esac ;; (add) case $MAIN_SUBCOMMAND in (pin) _arguments '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s)]' ;; (bootstrap) _arguments '--default[Add default bootstrap nodes]' ;; esac ;; (rm) case $MAIN_SUBCOMMAND in (pin) _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s)]' ;; (bootstrap) _arguments '--all[Remove all bootstrap peers.]' ;; esac ;; (ls) case $MAIN_SUBCOMMAND in (pin) _arguments \ '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Defaults to "recursive"]' \ '(-n --count)'{-n,--count}'[Show refcount when listing indirect pins]' \ '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects]' ;; esac ;; (findprovs|get|put|query) case $MAIN_SUBCOMMAND in (dht) _arguments '(-v --verbose)'{-v,--verbose}'[Write extra information]' ;; esac ;; (net) case $MAIN_SUBCOMMAND in (diag) _arguments '--vis[Output vis. one of: d3, dot]' ;; esac ;; (publish) case $MAIN_SUBCOMMAND in (name) _arguments \ '--resolve[Resolve given path before publishing (default=true)]' \ '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for (default: 24hrs)]' \ '--ttl[Time duration this record should be cached for (caution: experimental)]' ;; esac ;; (resolve) case $MAIN_SUBCOMMAND in (name) _arguments \ '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name]' \ '(-n --nocache)'{-n,--nocache}'[Do not used cached entries]' ;; esac ;; (patch) case $MAIN_SUBCOMMAND in (object) _arguments '(-p --create)'{-p,--create}'[Create intermediate directories on add-link]' ;; esac ;; (gc) case $MAIN_SUBCOMMAND in (repo) _arguments '(-q --quiet)'{-q,--quiet}'[Write minimal output]' ;; esac ;; (bw) case $MAIN_SUBCOMMAND in (stats) _arguments \ '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for]' \ '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for]' \ '--poll[Print bandwidth at an interval]' \ '(-i --interval)'{-i,--interval}'[Interval to wait between updating output]' ;; esac ;; esac ;; esac } local expl _arguments \ '(-c --config)'{-c,--config}'[Path to the configuration file to use]' \ '(-D --debug)'{-D,--debug}'[Operate in debug mode]' \ '(--help)--help[Show the full command help text]' \ '(--h)-h[Show a short version of the command help text]' \ '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon]' \ '(--api)--api[Overrides the routing option (dht, supernode)]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then _describe -t commands "ipfs subcommand" _1st_arguments return fi MAIN_SUBCOMMAND="$words[1]" case $MAIN_SUBCOMMAND in (add) _arguments \ '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively]' \ '(-q --quiet)'{-q,--quiet}'[Write minimal output]' \ '(-p --progress)'{-p,--progress}'[Stream progress data]' \ '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation]' \ '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk]' \ '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object]' \ '(-H --hidden)'{-h,--hidden}'[Include files that are hidden]' \ '(-s --chunker)'{-s,--chunker}'[chunking algorithm to use]' ;; (bitswap) local -a _bitswap_arguments _bitswap_arguments=( 'wantlist:Show blocks currently on the wantlist' 'stat:Show some diagnostic information on the bitswap agent' 'unwant: Remove a given block from your wantlist' ) _ipfs_subcommand _bitswap_arguments ;; (block) local -a _block_arguments _block_arguments=( 'stat: Print information of a raw IPFS block' 'get: Get a raw IPFS block' 'put: Stores input as an IPFS block' ) _ipfs_subcommand _block_arguments ;; (bootstrap) local -a _bootstrap_arguments _bootstrap_arguments=( 'add:[] Add peers to the bootstrap list' 'rm:[] Removes peers from the bootstrap list' 'list:Show peers in the bootstrap list' ) _ipfs_subcommand _bootstrap_arguments ;; (commands) _arguments '(-f --flags)'{-f,--flags}'[Show command flags]' ;; (config) _arguments \ '--bool[Set a boolean value]' \ '--json[Parse stringified JSON]' local -a _config_arguments _config_arguments=( 'show:Outputs the content of the config file' 'edit:Opens the config file for editing in $EDITOR' 'replace: Replaces the config with ' ) _ipfs_subcommand _config_arguments ;; (daemon) _arguments \ '--init[Initialize IPFS with default settings if not already initialized]' \ '--routing[Overrides the routing option (dht, supernode)]' \ '--mount[Mounts IPFS to the filesystem]' \ '--writable[Enable writing objects (with POST, PUT and DELETE)]' \ '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount)]' \ '--mount-ipns[Path to the mountpoint for IPNS (if using --mount)]' \ '--unrestricted-api[Allow API access to unlisted hashes]' \ '--disable-transport-encryption[Disable transport encryption (for debugging protocols)]' \ '--enable-gc[Enable automatic periodic repo garbage collection]' ;; (dht) local -a _dht_arguments _dht_arguments=( "query: Run a 'findClosestPeers' query through the DHT" "findprovs: Run a 'FindProviders' query through the DHT" "findpeer: Run a 'FindPeer' query through the DHT" "get: Run a 'GetValue' query through the DHT" "put: Run a 'PutValue' query through the DHT" ) _ipfs_subcommand _dht_arguments ;; (diag) local -a _diag_arguments _diag_arguments=( 'net:Generates a network diagnostics report' 'sys:Prints out system diagnostic information.' ) _ipfs_subcommand _diag_arguments ;; (dns) _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link]' ;; (file) local -a _file_arguments _file_arguments=( 'ls: List directory contents for Unix-filesystem objects' ) _ipfs_subcommand _file_arguments ;; (get) _arguments \ '(-o --output)'{-o,--output}'[The path where output should be stored]'\ '(-a --archive)'{-a,--archive}'[Output a TAR archive]' \ '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression]' \ '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9)]' ;; (id) _arguments '(-f --format)'{-f,--format}'[Optional output format]' ;; (init) _arguments \ '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key (defaults to 2048)]' \ '(-f --force)'{-f,--force}'[Overwrite existing config (if it exists)]' \ '(-e --empty-repo)'{-e,--empty-repo}'[Do not add and pin help files to the local storage]' ;; (log) local -a _log_arguments _log_arguments=( 'level: Change the logging level' 'tail:Read the logs' ) _ipfs_subcommand _log_arguments ;; (ls) _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Name, Size)]' ;; (mount) _arguments \ '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted]' \ '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted]' ;; (name) local -a _name_arguments _name_arguments=( 'publish: Publish an object to IPNS' 'resolve:[] Gets the value currently published at an IPNS name' ) _ipfs_subcommand _name_arguments ;; (object) local -a _object_arguments _object_arguments=( 'data: Outputs the raw bytes in an IPFS object' 'links: Outputs the links pointed to by the specified object' 'get: Get and serialize the DAG node named by ' 'put: Stores input as a DAG object, outputs its key' 'stat: Get stats for the DAG node named by ' 'new:[