mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 07:28:20 +08:00
re-enable the stdin
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
This commit is contained in:
@ -132,13 +132,13 @@ var bootstrapRemoveCmd = &cmds.Command{
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("peer", false, true, peerOptionDesc),
|
||||
cmds.StringArg("peer", false, true, peerOptionDesc).EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("all", "Remove all bootstrap peers.").Default(false),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
input, err := config.ParseBootstrapPeers(req.Arguments())
|
||||
all, _, err := req.Option("all").Bool()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
@ -156,16 +156,16 @@ var bootstrapRemoveCmd = &cmds.Command{
|
||||
return
|
||||
}
|
||||
|
||||
all, _, err := req.Option("all").Bool()
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
var removed []config.BootstrapPeer
|
||||
if all {
|
||||
removed, err = bootstrapRemoveAll(r, cfg)
|
||||
} else {
|
||||
input, perr := config.ParseBootstrapPeers(req.Arguments())
|
||||
if perr != nil {
|
||||
res.SetError(perr, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
removed, err = bootstrapRemove(r, cfg, input)
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -20,7 +20,7 @@ var CatCmd = &cmds.Command{
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted."),
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
node, err := req.InvocContext().GetNode()
|
||||
|
@ -459,7 +459,7 @@ NOTE: A value may not exceed 2048 bytes.
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("key", true, false, "The key to store the value at."),
|
||||
cmds.StringArg("value", true, false, "The value to store."),
|
||||
cmds.StringArg("value", true, false, "The value to store.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
|
||||
|
@ -44,7 +44,7 @@ The resolver can recursively resolve:
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("domain-name", true, false, "The domain-name name to resolve."),
|
||||
cmds.StringArg("domain-name", true, false, "The domain-name name to resolve.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("recursive", "r", "Resolve until the result is not a DNS link.").Default(false),
|
||||
|
@ -37,7 +37,7 @@ may also specify the level of compression by specifying '-l=<1-9>'.
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, false, "The path to the IPFS object(s) to be outputted."),
|
||||
cmds.StringArg("ipfs-path", true, false, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption("output", "o", "The path where the output should be stored."),
|
||||
|
@ -58,7 +58,7 @@ EXAMPLE:
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("peerid", false, false, "Peer.ID of node to look up."),
|
||||
cmds.StringArg("peerid", false, false, "Peer.ID of node to look up.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption("format", "f", "Optional output format."),
|
||||
|
@ -42,7 +42,7 @@ format:
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from."),
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
|
||||
|
@ -78,7 +78,7 @@ is the raw data of the object.
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format."),
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
@ -108,7 +108,7 @@ multihash.
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format."),
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
|
||||
@ -179,7 +179,7 @@ This command outputs data in the following encodings:
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format."),
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
@ -246,7 +246,7 @@ var ObjectStatCmd = &cmds.Command{
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format."),
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
|
@ -71,6 +71,11 @@ var addPinCmd = &cmds.Command{
|
||||
},
|
||||
Marshalers: cmds.MarshalerMap{
|
||||
cmds.Text: func(res cmds.Response) (io.Reader, error) {
|
||||
added, ok := res.Output().(*PinOutput)
|
||||
if !ok {
|
||||
return nil, u.ErrCast()
|
||||
}
|
||||
|
||||
var pintype string
|
||||
rec, found, _ := res.Request().Option("recursive").Bool()
|
||||
if rec || !found {
|
||||
@ -79,17 +84,11 @@ var addPinCmd = &cmds.Command{
|
||||
pintype = "directly"
|
||||
}
|
||||
|
||||
po, ok := res.Output().(*PinOutput)
|
||||
if !ok {
|
||||
return nil, u.ErrCast()
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
for _, k := range po.Pins {
|
||||
for _, k := range added.Pins {
|
||||
fmt.Fprintf(buf, "pinned %s %s\n", k, pintype)
|
||||
}
|
||||
return buf, nil
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ trip latency information.
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("peer ID", true, true, "ID of peer to be pinged."),
|
||||
cmds.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.IntOption("count", "n", "Number of ping messages to send.").Default(10),
|
||||
|
@ -47,7 +47,7 @@ Publish an <ipfs-path> to another public key (not implemented):
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, false, "IPFS path of the object to be published."),
|
||||
cmds.StringArg("ipfs-path", true, false, "IPFS path of the object to be published.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("resolve", "Resolve given path before publishing.").Default(true),
|
||||
|
@ -46,7 +46,7 @@ NOTE: List all references recursively by using the flag '-r'.
|
||||
"local": RefsLocalCmd,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from."),
|
||||
cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").Default("<dst>"),
|
||||
|
@ -56,7 +56,7 @@ Resolve the value of an IPFS DAG path:
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("name", true, false, "The name to resolve."),
|
||||
cmds.StringArg("name", true, false, "The name to resolve.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("recursive", "r", "Resolve until the result is an IPFS name.").Default(false),
|
||||
|
@ -215,7 +215,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("address", true, true, "Address of peer to connect to."),
|
||||
cmds.StringArg("address", true, true, "Address of peer to connect to.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
ctx := req.Context()
|
||||
@ -283,7 +283,7 @@ it will reconnect.
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("address", true, true, "Address of peer to disconnect from."),
|
||||
cmds.StringArg("address", true, true, "Address of peer to disconnect from.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
@ -451,7 +451,7 @@ add your filters to the ipfs config file.
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("address", true, true, "Multiaddr to filter."),
|
||||
cmds.StringArg("address", true, true, "Multiaddr to filter.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
@ -523,7 +523,7 @@ remove your filters from the ipfs config file.
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("address", true, true, "Multiaddr filter to remove."),
|
||||
cmds.StringArg("address", true, true, "Multiaddr filter to remove.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
n, err := req.InvocContext().GetNode()
|
||||
|
@ -83,7 +83,7 @@ var tarCatCmd = &cmds.Command{
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("path", true, false, "IPFS path of archive to export."),
|
||||
cmds.StringArg("path", true, false, "IPFS path of archive to export.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
nd, err := req.InvocContext().GetNode()
|
||||
|
@ -63,7 +63,7 @@ Example:
|
||||
},
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from."),
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from.").EnableStdin(),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
node, err := req.InvocContext().GetNode()
|
||||
|
@ -212,7 +212,7 @@ test_expect_success "ipfs cat output looks good" '
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat accept hash from built input" '
|
||||
echo "$HASH" | xargs ipfs cat >actual
|
||||
echo "$HASH" | ipfs cat >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat output looks good" '
|
||||
@ -268,7 +268,7 @@ test_expect_success "'ipfs add' output looks good" '
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs cat' with built input succeeds" '
|
||||
echo "$HASH" | xargs ipfs cat >actual
|
||||
echo "$HASH" | ipfs cat >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat with built input output looks good" '
|
||||
@ -319,7 +319,7 @@ test_expect_success "'ipfs add -rn' output looks good" '
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat accept many hashes from built input" '
|
||||
{ echo "$MARS"; echo "$VENUS"; } | xargs ipfs cat >actual
|
||||
{ echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat output looks good" '
|
||||
@ -335,28 +335,9 @@ test_expect_success "ipfs cat output looks good" '
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat with both arg and built input" '
|
||||
echo "$MARS" | xargs ipfs cat "$VENUS" >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat output looks good" '
|
||||
cat mountdir/planets/venus.txt mountdir/planets/mars.txt >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat with two args and built input" '
|
||||
echo "$MARS" | xargs ipfs cat "$VENUS" "$VENUS" >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs cat output looks good" '
|
||||
cat mountdir/planets/venus.txt mountdir/planets/venus.txt \
|
||||
mountdir/planets/mars.txt >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "go-random is installed" '
|
||||
type random
|
||||
'
|
||||
'
|
||||
|
||||
test_add_cat_5MB
|
||||
|
||||
|
Reference in New Issue
Block a user