Skip to content

Commit 5f64b27

Browse files
committed
cmdkit -> cmds
License: MIT Signed-off-by: Steven Allen <[email protected]>
1 parent 4b7a24f commit 5f64b27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+623
-680
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ Listing of the main packages used in the IPFS ecosystem. There are also three sp
353353
| [`go-ipfs-blockstore`](//github.com/ipfs/go-ipfs-blockstore) | [![Travis CI](https://travis-ci.com/ipfs/go-ipfs-blockstore.svg?branch=master)](https://travis-ci.com/ipfs/go-ipfs-blockstore) | [![codecov](https://codecov.io/gh/ipfs/go-ipfs-blockstore/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-blockstore) | blockstore interfaces and implementations |
354354
| **Commands** |
355355
| [`go-ipfs-cmds`](//github.com/ipfs/go-ipfs-cmds) | [![Travis CI](https://travis-ci.com/ipfs/go-ipfs-cmds.svg?branch=master)](https://travis-ci.com/ipfs/go-ipfs-cmds) | [![codecov](https://codecov.io/gh/ipfs/go-ipfs-cmds/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-cmds) | CLI & HTTP commands library |
356-
| [`go-ipfs-cmdkit`](//github.com/ipfs/go-ipfs-cmdkit) | [![Travis CI](https://travis-ci.com/ipfs/go-ipfs-cmdkit.svg?branch=master)](https://travis-ci.com/ipfs/go-ipfs-cmdkit) | [![codecov](https://codecov.io/gh/ipfs/go-ipfs-cmdkit/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-cmdkit) | helper types for the commands library |
357356
| [`go-ipfs-api`](//github.com/ipfs/go-ipfs-api) | [![Travis CI](https://travis-ci.com/ipfs/go-ipfs-api.svg?branch=master)](https://travis-ci.com/ipfs/go-ipfs-api) | [![codecov](https://codecov.io/gh/ipfs/go-ipfs-api/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-api) | a shell for the IPFS HTTP API |
358357
| **Metrics & Logging** |
359358
| [`go-metrics-interface`](//github.com/ipfs/go-metrics-interface) | [![Travis CI](https://travis-ci.com/ipfs/go-metrics-interface.svg?branch=master)](https://travis-ci.com/ipfs/go-metrics-interface) | [![codecov](https://codecov.io/gh/ipfs/go-metrics-interface/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-metrics-interface) | metrics collection interfaces |

cmd/ipfs/daemon.go

+21-22
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import (
2626
migrate "github.com/ipfs/go-ipfs/repo/fsrepo/migrations"
2727

2828
"github.com/hashicorp/go-multierror"
29-
"github.com/ipfs/go-ipfs-cmdkit"
30-
cmds "github.com/ipfs/go-ipfs-cmds"
29+
"github.com/ipfs/go-ipfs-cmds"
3130
mprome "github.com/ipfs/go-metrics-prometheus"
3231
goprocess "github.com/jbenet/goprocess"
3332
ma "github.com/multiformats/go-multiaddr"
@@ -62,7 +61,7 @@ const (
6261
)
6362

6463
var daemonCmd = &cmds.Command{
65-
Helptext: cmdkit.HelpText{
64+
Helptext: cmds.HelpText{
6665
Tagline: "Run a network-connected IPFS node.",
6766
ShortDescription: `
6867
'ipfs daemon' runs a persistent ipfs daemon that can serve commands
@@ -153,26 +152,26 @@ Headers.
153152
`,
154153
},
155154

156-
Options: []cmdkit.Option{
157-
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
158-
cmdkit.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
159-
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault(routingOptionDefaultKwd),
160-
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
161-
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
162-
cmdkit.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
163-
cmdkit.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
164-
cmdkit.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
165-
cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
166-
cmdkit.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
167-
cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
168-
cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
169-
cmdkit.BoolOption(enablePubSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
170-
cmdkit.BoolOption(enableIPNSPubSubKwd, "Enable IPNS record distribution through pubsub; enables pubsub."),
171-
cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
155+
Options: []cmds.Option{
156+
cmds.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
157+
cmds.StringOption(initProfileOptionKwd, "Configuration profiles to apply for --init. See ipfs init --help for more"),
158+
cmds.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault(routingOptionDefaultKwd),
159+
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
160+
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
161+
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
162+
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
163+
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
164+
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
165+
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
166+
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
167+
cmds.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
168+
cmds.BoolOption(enablePubSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
169+
cmds.BoolOption(enableIPNSPubSubKwd, "Enable IPNS record distribution through pubsub; enables pubsub."),
170+
cmds.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
172171

173172
// TODO: add way to override addresses. tricky part: updating the config if also --init.
174-
// cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
175-
// cmdkit.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
173+
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
174+
// cmds.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
176175
},
177176
Subcommands: map[string]*cmds.Command{},
178177
Run: daemonFunc,
@@ -384,7 +383,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
384383
// construct fuse mountpoints - if the user provided the --mount flag
385384
mount, _ := req.Options[mountKwd].(bool)
386385
if mount && offline {
387-
return cmdkit.Errorf(cmdkit.ErrClient, "mount is not currently supported in offline mode")
386+
return cmds.Errorf(cmds.ErrClient, "mount is not currently supported in offline mode")
388387
}
389388
if mount {
390389
if err := mountFuse(req, cctx); err != nil {

cmd/ipfs/init.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
namesys "github.com/ipfs/go-ipfs/namesys"
1717
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
1818

19-
"github.com/ipfs/go-ipfs-cmdkit"
2019
"github.com/ipfs/go-ipfs-cmds"
2120
"github.com/ipfs/go-ipfs-config"
2221
"github.com/ipfs/go-ipfs-files"
@@ -30,7 +29,7 @@ const (
3029
)
3130

3231
var initCmd = &cmds.Command{
33-
Helptext: cmdkit.HelpText{
32+
Helptext: cmds.HelpText{
3433
Tagline: "Initializes ipfs config file.",
3534
ShortDescription: `
3635
Initializes ipfs configuration files and generates a new keypair.
@@ -47,18 +46,18 @@ environment variable:
4746
export IPFS_PATH=/path/to/ipfsrepo
4847
`,
4948
},
50-
Arguments: []cmdkit.Argument{
51-
cmdkit.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
49+
Arguments: []cmds.Argument{
50+
cmds.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
5251
},
53-
Options: []cmdkit.Option{
54-
cmdkit.IntOption(bitsOptionName, "b", "Number of bits to use in the generated RSA private key.").WithDefault(nBitsForKeypairDefault),
55-
cmdkit.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage."),
56-
cmdkit.StringOption(profileOptionName, "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),
52+
Options: []cmds.Option{
53+
cmds.IntOption(bitsOptionName, "b", "Number of bits to use in the generated RSA private key.").WithDefault(nBitsForKeypairDefault),
54+
cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage."),
55+
cmds.StringOption(profileOptionName, "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),
5756

5857
// TODO need to decide whether to expose the override as a file or a
5958
// directory. That is: should we allow the user to also specify the
6059
// name of the file?
61-
// TODO cmdkit.StringOption("event-logs", "l", "Location for machine-readable event logs."),
60+
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs."),
6261
},
6362
PreRun: func(req *cmds.Request, env cmds.Environment) error {
6463
cctx := env.(*oldcmds.Context)

core/commands/active.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
oldcmds "github.com/ipfs/go-ipfs/commands"
1111

12-
cmdkit "github.com/ipfs/go-ipfs-cmdkit"
1312
cmds "github.com/ipfs/go-ipfs-cmds"
1413
)
1514

@@ -18,7 +17,7 @@ const (
1817
)
1918

2019
var ActiveReqsCmd = &cmds.Command{
21-
Helptext: cmdkit.HelpText{
20+
Helptext: cmds.HelpText{
2221
Tagline: "List commands run on this IPFS node.",
2322
ShortDescription: `
2423
Lists running and recently run commands.
@@ -28,8 +27,8 @@ Lists running and recently run commands.
2827
ctx := env.(*oldcmds.Context)
2928
return cmds.EmitOnce(res, ctx.ReqLog.Report())
3029
},
31-
Options: []cmdkit.Option{
32-
cmdkit.BoolOption(verboseOptionName, "v", "Print extra information."),
30+
Options: []cmds.Option{
31+
cmds.BoolOption(verboseOptionName, "v", "Print extra information."),
3332
},
3433
Subcommands: map[string]*cmds.Command{
3534
"clear": clearInactiveCmd,
@@ -86,7 +85,7 @@ Lists running and recently run commands.
8685
}
8786

8887
var clearInactiveCmd = &cmds.Command{
89-
Helptext: cmdkit.HelpText{
88+
Helptext: cmds.HelpText{
9089
Tagline: "Clear inactive requests from the log.",
9190
},
9291
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -97,11 +96,11 @@ var clearInactiveCmd = &cmds.Command{
9796
}
9897

9998
var setRequestClearCmd = &cmds.Command{
100-
Helptext: cmdkit.HelpText{
99+
Helptext: cmds.HelpText{
101100
Tagline: "Set how long to keep inactive requests in the log.",
102101
},
103-
Arguments: []cmdkit.Argument{
104-
cmdkit.StringArg("time", true, false, "Time to keep inactive requests in log."),
102+
Arguments: []cmds.Argument{
103+
cmds.StringArg("time", true, false, "Time to keep inactive requests in log."),
105104
},
106105
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
107106
tval, err := time.ParseDuration(req.Arguments[0])

core/commands/add.go

+20-21
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"github.com/ipfs/go-ipfs/core/commands/cmdenv"
1212

13-
cmdkit "github.com/ipfs/go-ipfs-cmdkit"
1413
cmds "github.com/ipfs/go-ipfs-cmds"
1514
"github.com/ipfs/go-ipfs-files"
1615
coreiface "github.com/ipfs/interface-go-ipfs-core"
@@ -51,7 +50,7 @@ const (
5150
const adderOutChanSize = 8
5251

5352
var AddCmd = &cmds.Command{
54-
Helptext: cmdkit.HelpText{
53+
Helptext: cmds.HelpText{
5554
Tagline: "Add a file or directory to ipfs.",
5655
ShortDescription: `
5756
Adds contents of <path> to ipfs. Use -r to add directories (recursively).
@@ -106,30 +105,30 @@ You can now check what blocks have been created by:
106105
`,
107106
},
108107

109-
Arguments: []cmdkit.Argument{
110-
cmdkit.FileArg("path", true, true, "The path to a file to be added to ipfs.").EnableRecursive().EnableStdin(),
108+
Arguments: []cmds.Argument{
109+
cmds.FileArg("path", true, true, "The path to a file to be added to ipfs.").EnableRecursive().EnableStdin(),
111110
},
112-
Options: []cmdkit.Option{
111+
Options: []cmds.Option{
113112
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
114113
cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args)
115114
cmds.OptionStdinName, // a builtin option that optionally allows wrapping stdin into a named file
116115
cmds.OptionHidden,
117-
cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."),
118-
cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."),
119-
cmdkit.BoolOption(silentOptionName, "Write no output."),
120-
cmdkit.BoolOption(progressOptionName, "p", "Stream progress data."),
121-
cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
122-
cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
123-
cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
124-
cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
125-
cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
126-
cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
127-
cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. Implies raw-leaves. (experimental)"),
128-
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
129-
cmdkit.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"),
130-
cmdkit.StringOption(hashOptionName, "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)").WithDefault("sha2-256"),
131-
cmdkit.BoolOption(inlineOptionName, "Inline small blocks into CIDs. (experimental)"),
132-
cmdkit.IntOption(inlineLimitOptionName, "Maximum block size to inline. (experimental)").WithDefault(32),
116+
cmds.BoolOption(quietOptionName, "q", "Write minimal output."),
117+
cmds.BoolOption(quieterOptionName, "Q", "Write only final hash."),
118+
cmds.BoolOption(silentOptionName, "Write no output."),
119+
cmds.BoolOption(progressOptionName, "p", "Stream progress data."),
120+
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
121+
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
122+
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
123+
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
124+
cmds.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
125+
cmds.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
126+
cmds.BoolOption(noCopyOptionName, "Add the file using filestore. Implies raw-leaves. (experimental)"),
127+
cmds.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
128+
cmds.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"),
129+
cmds.StringOption(hashOptionName, "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)").WithDefault("sha2-256"),
130+
cmds.BoolOption(inlineOptionName, "Inline small blocks into CIDs. (experimental)"),
131+
cmds.IntOption(inlineLimitOptionName, "Maximum block size to inline. (experimental)").WithDefault(32),
133132
},
134133
PreRun: func(req *cmds.Request, env cmds.Environment) error {
135134
quiet, _ := req.Options[quietOptionName].(bool)

core/commands/bitswap.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import (
1111
bitswap "github.com/ipfs/go-bitswap"
1212
decision "github.com/ipfs/go-bitswap/decision"
1313
cidutil "github.com/ipfs/go-cidutil"
14-
cmdkit "github.com/ipfs/go-ipfs-cmdkit"
1514
cmds "github.com/ipfs/go-ipfs-cmds"
1615
peer "github.com/libp2p/go-libp2p-peer"
1716
)
1817

1918
var BitswapCmd = &cmds.Command{
20-
Helptext: cmdkit.HelpText{
19+
Helptext: cmds.HelpText{
2120
Tagline: "Interact with the bitswap agent.",
2221
ShortDescription: ``,
2322
},
@@ -35,13 +34,13 @@ const (
3534
)
3635

3736
var showWantlistCmd = &cmds.Command{
38-
Helptext: cmdkit.HelpText{
37+
Helptext: cmds.HelpText{
3938
Tagline: "Show blocks currently on the wantlist.",
4039
ShortDescription: `
4140
Print out all blocks currently on the bitswap wantlist for the local peer.`,
4241
},
43-
Options: []cmdkit.Option{
44-
cmdkit.StringOption(peerOptionName, "p", "Specify which peer to show wantlist for. Default: self."),
42+
Options: []cmds.Option{
43+
cmds.StringOption(peerOptionName, "p", "Specify which peer to show wantlist for. Default: self."),
4544
},
4645
Type: KeyList{},
4746
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -94,13 +93,13 @@ const (
9493
)
9594

9695
var bitswapStatCmd = &cmds.Command{
97-
Helptext: cmdkit.HelpText{
96+
Helptext: cmds.HelpText{
9897
Tagline: "Show some diagnostic information on the bitswap agent.",
9998
ShortDescription: ``,
10099
},
101-
Options: []cmdkit.Option{
102-
cmdkit.BoolOption(bitswapVerboseOptionName, "v", "Print extra information"),
103-
cmdkit.BoolOption(bitswapHumanOptionName, "Print sizes in human readable format (e.g., 1K 234M 2G)"),
100+
Options: []cmds.Option{
101+
cmds.BoolOption(bitswapVerboseOptionName, "v", "Print extra information"),
102+
cmds.BoolOption(bitswapHumanOptionName, "Print sizes in human readable format (e.g., 1K 234M 2G)"),
104103
},
105104
Type: bitswap.Stat{},
106105
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -110,7 +109,7 @@ var bitswapStatCmd = &cmds.Command{
110109
}
111110

112111
if !nd.IsOnline {
113-
return cmdkit.Errorf(cmdkit.ErrClient, ErrNotOnline.Error())
112+
return cmds.Errorf(cmds.ErrClient, ErrNotOnline.Error())
114113
}
115114

116115
bs, ok := nd.Exchange.(*bitswap.Bitswap)
@@ -169,16 +168,16 @@ var bitswapStatCmd = &cmds.Command{
169168
}
170169

171170
var ledgerCmd = &cmds.Command{
172-
Helptext: cmdkit.HelpText{
171+
Helptext: cmds.HelpText{
173172
Tagline: "Show the current ledger for a peer.",
174173
ShortDescription: `
175174
The Bitswap decision engine tracks the number of bytes exchanged between IPFS
176175
nodes, and stores this information as a collection of ledgers. This command
177176
prints the ledger associated with a given peer.
178177
`,
179178
},
180-
Arguments: []cmdkit.Argument{
181-
cmdkit.StringArg("peer", true, false, "The PeerID (B58) of the ledger to inspect."),
179+
Arguments: []cmds.Argument{
180+
cmds.StringArg("peer", true, false, "The PeerID (B58) of the ledger to inspect."),
182181
},
183182
Type: decision.Receipt{},
184183
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -218,7 +217,7 @@ prints the ledger associated with a given peer.
218217
}
219218

220219
var reprovideCmd = &cmds.Command{
221-
Helptext: cmdkit.HelpText{
220+
Helptext: cmds.HelpText{
222221
Tagline: "Trigger reprovider.",
223222
ShortDescription: `
224223
Trigger reprovider to announce our data to network.

0 commit comments

Comments
 (0)