fiatjaf / noscl

Command line client for Nostr.
Other
269 stars 53 forks source link

Suggestion: <content> from STDIN when "-" #19

Closed HamishMacEwan closed 1 year ago

HamishMacEwan commented 2 years ago

And perhaps a --config= option.

HamishMacEwan commented 1 year ago

Thanks @x1ddos for the functionality.

I note that the merge was in November 2022 and so the current installation command:

go install github.com/fiatjaf/noscl@latest doesn't pick up the changes since v0.6.0 (Latest) dates from Feb 15, 2022

go install github.com/fiatjaf/noscl@master doesn't seem to pick up the changes (The "Usage:" information lacks the "-" guidance)

In either case the result of publishing with the "-" and pasting in some text is:

~/bin/noscl$ noscl publish -
Sent event d9a6b65846620e5299036d269a6e07beb597d2c3452e1cb97f6805dbd7b49918 to 'wss://nostr-verified.wellorder.net'.
Sent event d9a6b65846620e5299036d269a6e07beb597d2c3452e1cb97f6805dbd7b49918 to 'wss://nostr.zebedee.cloud'.
panic: send on closed channel

goroutine 20 [running]:
github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent.func1({0xc0003644b0, 0x22}, 0x1c?)
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:245 +0x406
created by github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:232 +0x3fa

Where it waits and no prompt returns. Using ctrl-D to terminate the stdin input then results in:

Sent event 251c77e855df77434c089ab7aa5c9040a56a891590d36781109ad7275f132702 to 'wss://nostr.zebedee.cloud'.
Sent event 251c77e855df77434c089ab7aa5c9040a56a891590d36781109ad7275f132702 to 'wss://nostr-verified.wellorder.net'.

Any suggestions or requests for further information gratefully received.

1ma commented 1 year ago

This feature works if applied directly on top of the 0.6.0 release, but master is broken.

To that end I forked the project (https://github.com/1ma/noscl) and tagged a 0.6.1 release that can read from STDIN while this mess is not solved upstream.

Install with go install github.com/1ma/noscl@latest

Exact changes from fiatjaf/noscl@0.6.0: https://github.com/1ma/noscl/compare/v0.6.0...v0.6.1

HamishMacEwan commented 1 year ago

Thank you for this version.

It still has the issues described earlier:

panic: send on closed channel

goroutine 54 [running]:
github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent.func1({0xc0001d0760, 0x19}, 0x1c?)
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:245 +0x406
created by github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:232 +0x3fa

But if I abandon my optimism that the relays that fail will return, remove them, the result is the same.

panic: send on closed channel

goroutine 37 [running]:
github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent.func1({0xc0004089a0, 0x19}, 0x0?)
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:245 +0x406
created by github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:232 +0x3fa
1ma commented 1 year ago

Sorry to hear that. On closer examination the bugs I hit at the time on master are other ones #51 #52.

Unfortunately I'm not able to reproduce this issue myself. After pasting the text, I hit enter a couple times then Ctrl+D to close STDIN (at this point noscl kicks into motion). Is this how you do it?

$ noscl publish -
Thanks @x1ddos for the functionality.

I note that the merge was in November 2022 and so the current installation command:

go install github.com/fiatjaf/noscl@latest doesn't pick up the changes since v0.6.0
(Latest) dates from Feb 15, 2022

go install github.com/fiatjaf/noscl@master doesn't seem to pick up the changes (The "Usage:" information lacks the "-" guidance)

Sent event 4c5f93e3f754a143c2851f827cfb9ef5d4730ff8141861e690b03d43aafed882 to 'wss://nostr.mutinywallet.com'.
Sent event 4c5f93e3f754a143c2851f827cfb9ef5d4730ff8141861e690b03d43aafed882 to 'wss://nostr.bitcoiner.social'.
Sent event 4c5f93e3f754a143c2851f827cfb9ef5d4730ff8141861e690b03d43aafed882 to 'wss://nos.lol'.
Sent event 4c5f93e3f754a143c2851f827cfb9ef5d4730ff8141861e690b03d43aafed882 to 'wss://nostr.mom'.
Seen 4c5f93e3f754a143c2851f827cfb9ef5d4730ff8141861e690b03d43aafed882 on 'wss://nos.lol'.
$ echo $?
0

I use this feature in conjunction with Unix pipes, something like this. It has seem to work reliably so far.

$ echo "waka waka" | noscl publish -
HamishMacEwan commented 1 year ago

That is how I do it and these are the results:

user@62cdea:~/bin/noscl6.1$ noscl publish -
In a broader sense, Valéry's quote could be seen as a cautionary reminder that not all intellectual or philosophical puzzles lead to substantial progress in understanding. Sometimes, they might merely reflect the limitations or paradoxical nature of our language or thought, rather than reveal new knowledge about the world.
Sent event cd2091357a5fe9e1a72a10271619f4c62f5206d31ef8fc9e1938a1c55f6dc94c to 'wss://nostream-production-5895.up.railway.app'.
Sent event cd2091357a5fe9e1a72a10271619f4c62f5206d31ef8fc9e1938a1c55f6dc94c to 'wss://relay.damus.io'.
Sent event cd2091357a5fe9e1a72a10271619f4c62f5206d31ef8fc9e1938a1c55f6dc94c to 'wss://nostr-verified.wellorder.net'.
Sent event cd2091357a5fe9e1a72a10271619f4c62f5206d31ef8fc9e1938a1c55f6dc94c to 'wss://nostr.bitcoiner.social'.
Sent event cd2091357a5fe9e1a72a10271619f4c62f5206d31ef8fc9e1938a1c55f6dc94c to 'wss://nostr.zebedee.cloud'.
panic: send on closed channel

goroutine 39 [running]:
github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent.func1({0xc000358930, 0x2d}, 0x0?)
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:245 +0x406
created by github.com/fiatjaf/go-nostr.(*RelayPool).PublishEvent
        /home/user/go/pkg/mod/github.com/fiatjaf/go-nostr@v0.6.2/relaypool.go:232 +0x3fa
user@62cdea:~/bin/noscl6.1$

Prior to your update it would hang until ctrl-C returned the command prompt.