ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.09k stars 3.01k forks source link

unix-friendly output for 'ipfs dht' commands #2494

Open hackergrrl opened 8 years ago

hackergrrl commented 8 years ago

Work Items

Today:

$ ipfs dht findprovs QmNmL1foPtvw25dWR41eeqW5YcLZJA5b3XoKrrBYUwKhnv
QmRc5iJERYKMjFsJ57jsxJhUjf86HL1WyqrQBTJrCCAnKN
* <peer.ID QmT3B2> says use <peer.ID QmPhm1> <peer.ID QmaL57> <peer.ID QmRv1G> <peer.ID QmYHk2> <peer.ID QmSoLn> <peer.ID QmXSyB> <peer.ID QmZyo1> <peer.ID QmRPhq> <peer.ID QmV7E3> <peer.ID QmNMeh> 
* <peer.ID QmRv1G> says use <peer.ID QmPhm1> <peer.ID QmaL57> <peer.ID QmT3B2> <peer.ID QmSNEN> <peer.ID QmYHk2> <peer.ID QmSoLn> <peer.ID QmXSyB> <peer.ID QmZyo1> <peer.ID QmUZax> <peer.ID QmRPhq> <peer.ID QmV7E3> <peer.ID QmNMeh> <peer.ID QmUDHg> <peer.ID QmSoLj> <peer.ID Qmda2A> <peer.ID QmVhJf> <peer.ID QmfBPE> <peer.ID QmZY7M> <peer.ID QmR5Cr> <peer.ID QmaSfi>

Imagined output:

$ ipfs dht findprovs QmNmL1foPtvw25dWR41eeqW5YcLZJA5b3XoKrrBYUwKhnv
QmNh2nZ3tWc8hbAbGNmfQQN9TmPAkpwKztjH8xZvcrv3eF
QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
...

Important properties:

  1. no errors inlined into output (or, use stderr at least)
  2. simple, newline-delimited output that is immediately usable for unix programs

This makes the commands much friendlier to unix scripts -- IDs can be grabbed and fed into e.g. ipfs dht findpeer more or less directly! We could still retain a -s|--simple option that gives short PeerIDs for existing compatibility, and keep -v|--verbose for detailed human output.


cc @whyrusleeping

whyrusleeping commented 8 years ago

Heres what I would like to see as output for the various subcommands of ipfs dht

And for each of those, a verbose flag that prints the dht debugging events as they come in, making sure there arent any missed event types.

hackergrrl commented 8 years ago

What format would you like to see for a PeerID?

whyrusleeping commented 8 years ago

peer IDs are just the Qm... hash

hackergrrl commented 8 years ago

One more: how about ipfs dht put?

whyrusleeping commented 8 years ago

ehm... i guess it should take input from a file or standard in, and print out the peer IDs of peers that it stored a record with

hackergrrl commented 8 years ago

I've tackled most of these with https://github.com/ipfs/go-ipfs/pull/2560, but two trickier pieces remain:

verbose output to stderr

Since all output comes from the daemon over a single channel, we'll need to wrap its output in a struct or similar so it can be multiplexed to (stdout, stderr) on the receiving end.

flag to list all records on ipfs dht get

Records are generally binary, so newline delimited output doesn't work here. We'll need to figure out how we'd like to format this output (newline'd base64? JSON?) to be maximally useful for users of this feature.