Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 78cb5d3

Browse files
committed
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)
1 parent 76bf64d commit 78cb5d3

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

commands.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Usage: jsipfs COMMAND [OPTIONS]
2+
3+
Available commands:
4+
5+
- [ ] bitswap stat Show some diagnostic information on the bitswap agent.
6+
- [ ] bitswap unwant Remove a given block from your wantlist.
7+
- [ ] bitswap wantlist Print out all blocks currently on the bitswap wantlist for the local peer.
8+
- [ ] block get Get a raw IPFS block
9+
- [ ] block put Stores input as an IPFS block
10+
- [ ] block rm Remove a raw IPFS block
11+
- [ ] block stat Print information of a raw IPFS block
12+
- [ ] bootstrap add Add peers to the bootstrap list
13+
- [ ] bootstrap list Show peers in the bootstrap list
14+
- [ ] bootstrap rm Removes peers from the bootstrap list
15+
- [ ] commands List all available commands
16+
- [ ] config Get and set IPFS config values
17+
- [ ] config edit Opens the config file for editing in $EDITOR
18+
- [ ] config replace Replaces the config with <file>
19+
- [ ] config show Outputs the content of the config file
20+
- [ ] daemon Start a long-running daemon process
21+
- [ ] dns
22+
- [ ] files add Add a file to IPFS using the UnixFS data format
23+
- [ ] files cat Download IPFS objects
24+
- [ ] files get Download IPFS objects
25+
- [ ] id Shows IPFS Node ID info
26+
- [ ] init Initialize a local IPFS node
27+
- [ ] ls
28+
- [ ] mount
29+
- [ ] object data Outputs the raw bytes in an IPFS object
30+
- [ ] object get Get and serialize the DAG node named by <key>
31+
- [ ] object links Outputs the links pointed to by the specified object
32+
- [ ] object new Create new ipfs objects
33+
- [ ] object patch add-link Add a link to a given object
34+
- [ ] object patch append-data Append data to the data segment of a dag node
35+
- [ ] object patch rm-link Remove a link from an object
36+
- [ ] object patch set-data Set data field of an ipfs object
37+
- [ ] object put Stores input as a DAG object, outputs its key
38+
- [ ] object stat Get stats for the DAG node named by <key>
39+
- [ ] ping
40+
- [ ] refs
41+
- [ ] repo gc
42+
- [ ] repo init
43+
- [ ] repo version Shows IPFS repo version information
44+
- [ ] resolve
45+
- [ ] swarm addrs
46+
- [ ] swarm addrs local List local addresses
47+
- [ ] swarm connect Open connection to a given address
48+
- [ ] swarm disconnect
49+
- [ ] swarm peers List peers with open connections
50+
- [ ] update
51+
- [ ] version Shows IPFS version information

src/cli/commands/id.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ log.error = debug('cli:error')
99
module.exports = Command.extend({
1010
desc: 'Shows IPFS Node ID info',
1111

12+
help: utils.help,
13+
1214
options: {
1315
format: {
1416
alias: 'f',

src/cli/utils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ exports.getIPFS = (callback) => {
4646
callback(null, getAPICtl())
4747
}
4848

49+
exports.help = function () {
50+
var keys = []
51+
for (var key in this.options) {
52+
var keyString = '['
53+
if (this.options.hasOwnProperty(key)) {
54+
if (this.options[key].alias) {
55+
keyString += '-' + this.options[key].alias + ' | '
56+
}
57+
keyString += `--` + key + ']'
58+
keys.push(keyString)
59+
}
60+
}
61+
62+
return `USAGE:
63+
ipfs ${this.name} - ${this.desc}
64+
65+
SYNOPSIS:
66+
ipfs ${this.name} ${keys.join(' ')}
67+
`;
68+
}
69+
4970
exports.getRepoPath = () => {
5071
return process.env.IPFS_PATH || os.homedir() + '/.ipfs'
5172
}

0 commit comments

Comments
 (0)