Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdkit -> cmds #6318

Merged
merged 1 commit into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ Listing of the main packages used in the IPFS ecosystem. There are also three sp
| [`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 |
| **Commands** |
| [`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 |
| [`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 |
| [`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 |
| **Metrics & Logging** |
| [`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 |
Expand Down
43 changes: 21 additions & 22 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import (
migrate "github.com/ipfs/go-ipfs/repo/fsrepo/migrations"

"github.com/hashicorp/go-multierror"
"github.com/ipfs/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/go-ipfs-cmds"
mprome "github.com/ipfs/go-metrics-prometheus"
goprocess "github.com/jbenet/goprocess"
ma "github.com/multiformats/go-multiaddr"
Expand Down Expand Up @@ -62,7 +61,7 @@ const (
)

var daemonCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Run a network-connected IPFS node.",
ShortDescription: `
'ipfs daemon' runs a persistent ipfs daemon that can serve commands
Expand Down Expand Up @@ -153,26 +152,26 @@ Headers.
`,
},

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

// TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
// cmdkit.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
// cmds.StringOption(swarmAddrKwd, "Address for the swarm socket (overrides config)"),
},
Subcommands: map[string]*cmds.Command{},
Run: daemonFunc,
Expand Down Expand Up @@ -384,7 +383,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
// construct fuse mountpoints - if the user provided the --mount flag
mount, _ := req.Options[mountKwd].(bool)
if mount && offline {
return cmdkit.Errorf(cmdkit.ErrClient, "mount is not currently supported in offline mode")
return cmds.Errorf(cmds.ErrClient, "mount is not currently supported in offline mode")
}
if mount {
if err := mountFuse(req, cctx); err != nil {
Expand Down
17 changes: 8 additions & 9 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
namesys "github.com/ipfs/go-ipfs/namesys"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

"github.com/ipfs/go-ipfs-cmdkit"
"github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/go-ipfs-config"
"github.com/ipfs/go-ipfs-files"
Expand All @@ -30,7 +29,7 @@ const (
)

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

// TODO need to decide whether to expose the override as a file or a
// directory. That is: should we allow the user to also specify the
// name of the file?
// TODO cmdkit.StringOption("event-logs", "l", "Location for machine-readable event logs."),
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs."),
},
PreRun: func(req *cmds.Request, env cmds.Environment) error {
cctx := env.(*oldcmds.Context)
Expand Down
15 changes: 7 additions & 8 deletions core/commands/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

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

cmdkit "github.com/ipfs/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs-cmds"
)

Expand All @@ -18,7 +17,7 @@ const (
)

var ActiveReqsCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "List commands run on this IPFS node.",
ShortDescription: `
Lists running and recently run commands.
Expand All @@ -28,8 +27,8 @@ Lists running and recently run commands.
ctx := env.(*oldcmds.Context)
return cmds.EmitOnce(res, ctx.ReqLog.Report())
},
Options: []cmdkit.Option{
cmdkit.BoolOption(verboseOptionName, "v", "Print extra information."),
Options: []cmds.Option{
cmds.BoolOption(verboseOptionName, "v", "Print extra information."),
},
Subcommands: map[string]*cmds.Command{
"clear": clearInactiveCmd,
Expand Down Expand Up @@ -86,7 +85,7 @@ Lists running and recently run commands.
}

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

var setRequestClearCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Set how long to keep inactive requests in the log.",
},
Arguments: []cmdkit.Argument{
cmdkit.StringArg("time", true, false, "Time to keep inactive requests in log."),
Arguments: []cmds.Argument{
cmds.StringArg("time", true, false, "Time to keep inactive requests in log."),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
tval, err := time.ParseDuration(req.Arguments[0])
Expand Down
41 changes: 20 additions & 21 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

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

cmdkit "github.com/ipfs/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/go-ipfs-files"
coreiface "github.com/ipfs/interface-go-ipfs-core"
Expand Down Expand Up @@ -51,7 +50,7 @@ const (
const adderOutChanSize = 8

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

Arguments: []cmdkit.Argument{
cmdkit.FileArg("path", true, true, "The path to a file to be added to ipfs.").EnableRecursive().EnableStdin(),
Arguments: []cmds.Argument{
cmds.FileArg("path", true, true, "The path to a file to be added to ipfs.").EnableRecursive().EnableStdin(),
},
Options: []cmdkit.Option{
Options: []cmds.Option{
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args)
cmds.OptionStdinName, // a builtin option that optionally allows wrapping stdin into a named file
cmds.OptionHidden,
cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."),
cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."),
cmdkit.BoolOption(silentOptionName, "Write no output."),
cmdkit.BoolOption(progressOptionName, "p", "Stream progress data."),
cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. Implies raw-leaves. (experimental)"),
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
cmdkit.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"),
cmdkit.StringOption(hashOptionName, "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)").WithDefault("sha2-256"),
cmdkit.BoolOption(inlineOptionName, "Inline small blocks into CIDs. (experimental)"),
cmdkit.IntOption(inlineLimitOptionName, "Maximum block size to inline. (experimental)").WithDefault(32),
cmds.BoolOption(quietOptionName, "q", "Write minimal output."),
cmds.BoolOption(quieterOptionName, "Q", "Write only final hash."),
cmds.BoolOption(silentOptionName, "Write no output."),
cmds.BoolOption(progressOptionName, "p", "Stream progress data."),
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
cmds.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
cmds.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
cmds.BoolOption(noCopyOptionName, "Add the file using filestore. Implies raw-leaves. (experimental)"),
cmds.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
cmds.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"),
cmds.StringOption(hashOptionName, "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)").WithDefault("sha2-256"),
cmds.BoolOption(inlineOptionName, "Inline small blocks into CIDs. (experimental)"),
cmds.IntOption(inlineLimitOptionName, "Maximum block size to inline. (experimental)").WithDefault(32),
},
PreRun: func(req *cmds.Request, env cmds.Environment) error {
quiet, _ := req.Options[quietOptionName].(bool)
Expand Down
27 changes: 13 additions & 14 deletions core/commands/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import (
bitswap "github.com/ipfs/go-bitswap"
decision "github.com/ipfs/go-bitswap/decision"
cidutil "github.com/ipfs/go-cidutil"
cmdkit "github.com/ipfs/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs-cmds"
peer "github.com/libp2p/go-libp2p-peer"
)

var BitswapCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Interact with the bitswap agent.",
ShortDescription: ``,
},
Expand All @@ -35,13 +34,13 @@ const (
)

var showWantlistCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Show blocks currently on the wantlist.",
ShortDescription: `
Print out all blocks currently on the bitswap wantlist for the local peer.`,
},
Options: []cmdkit.Option{
cmdkit.StringOption(peerOptionName, "p", "Specify which peer to show wantlist for. Default: self."),
Options: []cmds.Option{
cmds.StringOption(peerOptionName, "p", "Specify which peer to show wantlist for. Default: self."),
},
Type: KeyList{},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
Expand Down Expand Up @@ -94,13 +93,13 @@ const (
)

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

if !nd.IsOnline {
return cmdkit.Errorf(cmdkit.ErrClient, ErrNotOnline.Error())
return cmds.Errorf(cmds.ErrClient, ErrNotOnline.Error())
}

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

var ledgerCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Show the current ledger for a peer.",
ShortDescription: `
The Bitswap decision engine tracks the number of bytes exchanged between IPFS
nodes, and stores this information as a collection of ledgers. This command
prints the ledger associated with a given peer.
`,
},
Arguments: []cmdkit.Argument{
cmdkit.StringArg("peer", true, false, "The PeerID (B58) of the ledger to inspect."),
Arguments: []cmds.Argument{
cmds.StringArg("peer", true, false, "The PeerID (B58) of the ledger to inspect."),
},
Type: decision.Receipt{},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
Expand Down Expand Up @@ -218,7 +217,7 @@ prints the ledger associated with a given peer.
}

var reprovideCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Helptext: cmds.HelpText{
Tagline: "Trigger reprovider.",
ShortDescription: `
Trigger reprovider to announce our data to network.
Expand Down
Loading