hypercore-protocol / cli

A CLI for peer-to-peer file sharing using the Hypercore Protocol.
MIT License
205 stars 17 forks source link

--only/--quiet/… option for hyp create #43

Open Treora opened 3 years ago

Treora commented 3 years ago

For use in shell scripts or to pipe hyp’s output into other commands, it would be practical to have an option to only get the address of the created drive/bee from hyp create. Example output, currently:

> hyp create drive
Drive Created: hyper://87f05a94b1916674fb00d4cf4da0ed3ae9d9491ebd706afbb01e2a83332f4a4e
Seeding hyperdrive

The line containing the address appears to be output via stderr, not stdout, so currently some juggling like this is required to read only the hyper://… address:

hyp create drive 2>&1 | grep -oE "hyper://\w+"

An -o/--only option (like grep) or -q/--quiet option (like many tools) that makes hyp output only the hyper://… url could be helpful.

ghost commented 3 years ago

grep -oE "hyper://\w+"

depending on distro/version this is might not produce expected result,

grep -Eoe 'hyper://[0-9a-z]+' is more universal solution

ghost commented 3 years ago

i can see the value for --only, but would --quiet option be usable in any way within context of the cli?

it will create new empty drive with unknown address and start seeding.. emptiness? like, its a cute metaphor, but not very actionable

Treora commented 3 years ago

i can see the value for --only, but would --quiet option be usable in any way within context of the cli?

I suggested the two as alternative names for this option, not as two different options. Like with some other software, a single --quiet need not be completely silent (I’ve seen programs that hush all output if multiple -qs are passed).

ghost commented 3 years ago

multiple -qs are passed

it's probably not entirely universal either:

$ docker ps -a -q
0169d163346e
$ docker ps -a
CONTAINER ID   IMAGE               COMMAND   CREATED          STATUS                    PORTS                                                                                                                                                                                                                 NAMES
0169d163346e   analogic/poste.io   "/init"   18 minutes ago   Up 18 minutes (healthy)   110/tcp, 143/tcp, 465/tcp, 0.0.0.0:25->25/tcp, :::25->25/tcp, 587/tcp, 995/tcp, 0.0.0.0:993->993/tcp, :::993->993/tcp, 4190/tcp, 0.0.0.0:12080->80/tcp, :::12080->80/tcp, 0.0.0.0:12443->443/tcp, :::12443->443/tcp   mailserver
$ docker ps -q
0169d163346e
$ docker ps -qq
0169d163346e
$ docker ps -q -q
0169d163346e
$ docker ps -qqq
0169d163346e
$ docker ps -q -q -q
0169d163346e