Skip to content

Commit

Permalink
added input pipe ('-') and input streaming ('_') to --publish, --publ…
Browse files Browse the repository at this point in the history
…ish-pow and --dm
  • Loading branch information
8go committed Dec 15, 2022
1 parent c3d9d07 commit 0627924
Show file tree
Hide file tree
Showing 6 changed files with 474 additions and 59 deletions.
34 changes: 23 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "nostr-commander"
version = "0.0.8"
version = "0.0.9"
edition = "2021"
description = "simple but convenient CLI-based Nostr client app for publishing,sending and subscribing"
documentation = "https://docs.rs/nostr-commander"
Expand Down Expand Up @@ -32,6 +32,7 @@ directories = "4.0"
update-informer = "0.5"
chrono = "0.4"
json = "0.12"
atty = "0.2"


[dev-dependencies]
Expand Down
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,48 @@ Options:
be queried via the keyboard. If you want to set it to empty and not
be queried, provide an empty string ''
-p, --publish [<NOTE>...]
Publish one or multiple notes
Publish one or multiple notes. Notes data must not be binary data, it
must be text. Input piped via stdin can additionally be specified
with the special character '-'. If you want to feed a text message
into the program via a pipe, via stdin, then specify the special
character '-'. If your message is literally a single letter '-' then
use an escaped '\-' or a quoted "\-". Depending on your shell, '-'
might need to be escaped. If this is the case for your shell, use the
escaped '\-' instead of '-' and '\\-' instead of '\-'. However,
depending on which shell you are using and if you are quoting with
double quotes or with single quotes, you may have to add backslashes
to achieve the proper escape sequences. If you want to read the
message from the keyboard use '-' and do not pipe anything into
stdin, then a message will be requested and read from the keyboard.
Keyboard input is limited to one line. The stdin indicator '-' may
appear in any position, i.e. --publish 'start' '-' 'end' will send 3
messages out of which the second one is read from stdin. The stdin
indicator '-' may appear only once overall in all arguments. '-'
reads everything that is in the pipe in one swoop and sends a single
message. Similar to '-', another shortcut character is '_'. The
special character '_' is used for streaming data via a pipe on stdin.
With '_' the stdin pipe is read line-by-line and each line is treated
as a separate message and sent right away. The program waits for pipe
input until the pipe is closed. E.g. Imagine a tool that generates
output sporadically 24x7. It can be piped, i.e. streamed, into
nostr-commander, and nostr-commander stays active, sending all input
instantly. If you want to send the literal letter '_' then escape it
and send '\_'. '_' can be used only once. And either '-' or '_' can
be used
--publish-pow [<NOTE>...]
Publish one or multiple notes with proof-of-work (POW). Use also
'--pow-difficulty' to specify difficulty
'--pow-difficulty' to specify difficulty. See also '--publish' to see
how shortcut characters '-' (pipe) and '_' (streamed pipe) are
handled
--dm [<KEY+MSGS>...]
Send one or multiple DMs to one given user. DM messages will be
encrypted and preserve privacy. The single recipient is specified via
its public key, a string in the form of 'npub1...', a Hex key, or an
alias from one of your contacts. The first argument is the recipient,
all further arguments are texts to be sent. E.g. '-dm
'npub1SomeStrangeNumbers "First msg" "Second msg"' or 'dm joe "How
about pizza tonight?"'
about pizza tonight?"'. See also '--publish' to see how shortcut
characters '-' (pipe) and '_' (streamed pipe) are handled
--add-relay [<RELAY_URI>...]
Add one or multiple relays. A relay is specified via a URI that looks
like 'wss://some.relay.org'. You can find relays by looking at
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.8
0.0.9
36 changes: 33 additions & 3 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,48 @@ Options:
be queried via the keyboard. If you want to set it to empty and not
be queried, provide an empty string ''
-p, --publish [<NOTE>...]
Publish one or multiple notes
Publish one or multiple notes. Notes data must not be binary data, it
must be text. Input piped via stdin can additionally be specified
with the special character '-'. If you want to feed a text message
into the program via a pipe, via stdin, then specify the special
character '-'. If your message is literally a single letter '-' then
use an escaped '\-' or a quoted "\-". Depending on your shell, '-'
might need to be escaped. If this is the case for your shell, use the
escaped '\-' instead of '-' and '\\-' instead of '\-'. However,
depending on which shell you are using and if you are quoting with
double quotes or with single quotes, you may have to add backslashes
to achieve the proper escape sequences. If you want to read the
message from the keyboard use '-' and do not pipe anything into
stdin, then a message will be requested and read from the keyboard.
Keyboard input is limited to one line. The stdin indicator '-' may
appear in any position, i.e. --publish 'start' '-' 'end' will send 3
messages out of which the second one is read from stdin. The stdin
indicator '-' may appear only once overall in all arguments. '-'
reads everything that is in the pipe in one swoop and sends a single
message. Similar to '-', another shortcut character is '_'. The
special character '_' is used for streaming data via a pipe on stdin.
With '_' the stdin pipe is read line-by-line and each line is treated
as a separate message and sent right away. The program waits for pipe
input until the pipe is closed. E.g. Imagine a tool that generates
output sporadically 24x7. It can be piped, i.e. streamed, into
nostr-commander, and nostr-commander stays active, sending all input
instantly. If you want to send the literal letter '_' then escape it
and send '\_'. '_' can be used only once. And either '-' or '_' can
be used
--publish-pow [<NOTE>...]
Publish one or multiple notes with proof-of-work (POW). Use also
'--pow-difficulty' to specify difficulty
'--pow-difficulty' to specify difficulty. See also '--publish' to see
how shortcut characters '-' (pipe) and '_' (streamed pipe) are
handled
--dm [<KEY+MSGS>...]
Send one or multiple DMs to one given user. DM messages will be
encrypted and preserve privacy. The single recipient is specified via
its public key, a string in the form of 'npub1...', a Hex key, or an
alias from one of your contacts. The first argument is the recipient,
all further arguments are texts to be sent. E.g. '-dm
'npub1SomeStrangeNumbers "First msg" "Second msg"' or 'dm joe "How
about pizza tonight?"'
about pizza tonight?"'. See also '--publish' to see how shortcut
characters '-' (pipe) and '_' (streamed pipe) are handled
--add-relay [<RELAY_URI>...]
Add one or multiple relays. A relay is specified via a URI that looks
like 'wss://some.relay.org'. You can find relays by looking at
Expand Down
Loading

0 comments on commit 0627924

Please sign in to comment.