From 78cb5d3d1665927d7a849493e1ac5187007dbca6 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Thu, 30 Jun 2016 13:15:08 +0100 Subject: [PATCH] Update help function This makes the OPTIONS output a bit better. See #331. Do not merge this, for now, as we may be replacing the js- and go-ipfs docs with an intermediary; storing this here as an example of how to implement help in [ronin](https://www.npmjs.com/package/ronin) --- commands.md | 51 ++++++++++++++++++++++++++++++++++++++++++ src/cli/commands/id.js | 2 ++ src/cli/utils.js | 21 +++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 commands.md diff --git a/commands.md b/commands.md new file mode 100644 index 0000000000..3eb880a794 --- /dev/null +++ b/commands.md @@ -0,0 +1,51 @@ +Usage: jsipfs COMMAND [OPTIONS] + +Available commands: + +- [ ] bitswap stat Show some diagnostic information on the bitswap agent. +- [ ] bitswap unwant Remove a given block from your wantlist. +- [ ] bitswap wantlist Print out all blocks currently on the bitswap wantlist for the local peer. +- [ ] block get Get a raw IPFS block +- [ ] block put Stores input as an IPFS block +- [ ] block rm Remove a raw IPFS block +- [ ] block stat Print information of a raw IPFS block +- [ ] bootstrap add Add peers to the bootstrap list +- [ ] bootstrap list Show peers in the bootstrap list +- [ ] bootstrap rm Removes peers from the bootstrap list +- [ ] commands List all available commands +- [ ] config Get and set IPFS config values +- [ ] config edit Opens the config file for editing in $EDITOR +- [ ] config replace Replaces the config with +- [ ] config show Outputs the content of the config file +- [ ] daemon Start a long-running daemon process +- [ ] dns +- [ ] files add Add a file to IPFS using the UnixFS data format +- [ ] files cat Download IPFS objects +- [ ] files get Download IPFS objects +- [ ] id Shows IPFS Node ID info +- [ ] init Initialize a local IPFS node +- [ ] ls +- [ ] mount +- [ ] object data Outputs the raw bytes in an IPFS object +- [ ] object get Get and serialize the DAG node named by +- [ ] object links Outputs the links pointed to by the specified object +- [ ] object new Create new ipfs objects +- [ ] object patch add-link Add a link to a given object +- [ ] object patch append-data Append data to the data segment of a dag node +- [ ] object patch rm-link Remove a link from an object +- [ ] object patch set-data Set data field of an ipfs object +- [ ] object put Stores input as a DAG object, outputs its key +- [ ] object stat Get stats for the DAG node named by +- [ ] ping +- [ ] refs +- [ ] repo gc +- [ ] repo init +- [ ] repo version Shows IPFS repo version information +- [ ] resolve +- [ ] swarm addrs +- [ ] swarm addrs local List local addresses +- [ ] swarm connect Open connection to a given address +- [ ] swarm disconnect +- [ ] swarm peers List peers with open connections +- [ ] update +- [ ] version Shows IPFS version information diff --git a/src/cli/commands/id.js b/src/cli/commands/id.js index 775b4673f4..bd155360d8 100644 --- a/src/cli/commands/id.js +++ b/src/cli/commands/id.js @@ -9,6 +9,8 @@ log.error = debug('cli:error') module.exports = Command.extend({ desc: 'Shows IPFS Node ID info', + help: utils.help, + options: { format: { alias: 'f', diff --git a/src/cli/utils.js b/src/cli/utils.js index c592734897..8bbde819a1 100644 --- a/src/cli/utils.js +++ b/src/cli/utils.js @@ -46,6 +46,27 @@ exports.getIPFS = (callback) => { callback(null, getAPICtl()) } +exports.help = function () { + var keys = [] + for (var key in this.options) { + var keyString = '[' + if (this.options.hasOwnProperty(key)) { + if (this.options[key].alias) { + keyString += '-' + this.options[key].alias + ' | ' + } + keyString += `--` + key + ']' + keys.push(keyString) + } + } + + return `USAGE: + ipfs ${this.name} - ${this.desc} + +SYNOPSIS: + ipfs ${this.name} ${keys.join(' ')} +`; +} + exports.getRepoPath = () => { return process.env.IPFS_PATH || os.homedir() + '/.ipfs' }