oh-my-zsh/plugins/ipfs/_ipfs

388 lines
13 KiB
Plaintext
Raw Normal View History

#compdef ipfs
#autoload
local -a _1st_arguments
_1st_arguments=(
'add:<path> 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:<ipfs-path> Show IPFS object data'
'commands:List all available commands.'
'config:<key> [<value>] 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:<domain-name> DNS link resolver'
'file:Interact with ipfs objects representing Unix filesystems'
'get:Download IPFS objects'
'id:[<peer-id>] Show IPFS Node ID info'
'init:Initializes IPFS config file'
'log:Interact with the daemon log output'
'ls:<ipfs-path> 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:<peer ID> Send echo request packets to IPFS hosts'
'refs:<ipfs-path> 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:[<id>] 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:<key> Remove a given block from your wantlist'
)
_ipfs_subcommand _bitswap_arguments
;;
(block)
local -a _block_arguments
_block_arguments=(
'stat:<key> Print information of a raw IPFS block'
'get:<key> Get a raw IPFS block'
'put:<data> Stores input as an IPFS block'
)
_ipfs_subcommand _block_arguments
;;
(bootstrap)
local -a _bootstrap_arguments
_bootstrap_arguments=(
'add:[<peer>] Add peers to the bootstrap list'
'rm:[<peer>] 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:<file> Replaces the config with <file>'
)
_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:<peerID> Run a 'findClosestPeers' query through the DHT"
"findprovs:<key> Run a 'FindProviders' query through the DHT"
"findpeer:<peerID> Run a 'FindPeer' query through the DHT"
"get:<key> Run a 'GetValue' query through the DHT"
"put:<key> <value> 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:<ipfs-path> 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:<subsystem> <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:<ipfs-path> Publish an object to IPNS'
'resolve:[<name>] Gets the value currently published at an IPNS name'
)
_ipfs_subcommand _name_arguments
;;
(object)
local -a _object_arguments
_object_arguments=(
'data:<key> Outputs the raw bytes in an IPFS object'
'links:<key> Outputs the links pointed to by the specified object'
'get:<key> Get and serialize the DAG node named by <key>'
'put:<data> Stores input as a DAG object, outputs its key'
'stat:<key> Get stats for the DAG node named by <key>'
'new:[<template>] creates a new object from an ipfs template'
'patch:<root> <command> <args> Create a new merkledag object based on an existing one'
)
_ipfs_subcommand _object_arguments
;;
(pin)
local -a _pin_arguments
_pin_arguments=(
'add:<ipfs-path> Pins objects to local storage'
'rm:<ipfs-path> Removes the pinned object from local storage. (By default, recursively. Use -r=false for direct pins)'
'ls:List objects pinned to local storage'
)
_ipfs_subcommand _pin_arguments
;;
(ping)
_arguments '(-n --count)'{-n,--count}'[Number of ping messages to send]'
;;
(refs)
_arguments \
'--format[Emit edges with given format. tokens: <src> <dst> <linkname>]' \
'(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`]' \
'(-u --unique)'{-u,--unique}'[Omit duplicate refs from output]' \
'(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes]'
local -a _refs_arguments
_refs_arguments='local:Lists all local references'
_ipfs_subcommand _refs_arguments
;;
(repo)
local -a _repo_arguments
_repo_arguments='gc:Perform a garbage collection sweep on the repo'
_ipfs_subcommand _repo_arguments
;;
(resolve)
_arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name]'
;;
(stats)
local -a _stats_arguments
_stats_arguments='bw:Print ipfs bandwidth information'
_ipfs_subcommand _stats_arguments
;;
(swarm)
# TODO add level 3 subcommand autocompletion for `addrs` and `filters`
local -a _swarm_arguments
_swarm_arguments=(
'addrs:List known addresses. Useful to debug.'
'connect:<address> Open connection to a given address'
'disconnect:<address> Close connection to a given address'
'filters:Manipulate address filters'
'peers:List peers with open connections'
)
_ipfs_subcommand _swarm_arguments
;;
(tar)
local -a _tar_arguments
_tar_arguments=(
'add:<file> Import a tar file into ipfs'
'cat:<path> Export a tar file from ipfs'
)
_ipfs_subcommand _tar_arguments
;;
(tour)
local -a _tour_arguments
_tour_arguments=(
'list:Show a list of IPFS Tour topics'
'next:Show the next IPFS Tour topic'
'restart:Restart the IPFS Tour'
)
_ipfs_subcommand _tour_arguments
;;
(version)
_arguments \
'(-n --number)'{-n,--number}'[Only show the version number]' \
'--commit[Show the commit hash]' \
'--repo[Show repo version]'
;;
esac