summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-04-15 23:12:18 -0700
committerBen Sima <ben@bsima.me>2020-04-15 23:12:18 -0700
commitf79cfe42aac5f5cef8865f7a6975f6a430c923a1 (patch)
tree20d0f7e1746df04e2d9a553b4c1de99505efb83c
parentbfa8e3b88e247e40c2c4fc1ab03176599cc4170b (diff)
Use python format strings for args.then
-rwxr-xr-xQue/client.py6
-rw-r--r--Que/quescripts.md8
-rw-r--r--Que/tutorial.md2
3 files changed, 7 insertions, 9 deletions
diff --git a/Que/client.py b/Que/client.py
index f4ee601..1063eb8 100755
--- a/Que/client.py
+++ b/Que/client.py
@@ -96,9 +96,7 @@ def then(args, msg):
if args.then:
logging.debug("then")
subprocess.run(
- args.then.replace(r"\msg", msg).replace(r"\que", args.target),
- check=False,
- shell=True,
+ args.then.format(msg=msg, que=args.target), check=False, shell=True,
)
@@ -144,7 +142,7 @@ def get_args():
[
"when polling, run this shell command after each response,",
"presumably for side effects,"
- r"replacing '\que' with the target and '\msg' with the body of the response",
+ r"replacing '{que}' with the target and '{msg}' with the body of the response",
]
),
)
diff --git a/Que/quescripts.md b/Que/quescripts.md
index 9a2e6e0..77e7004 100644
--- a/Que/quescripts.md
+++ b/Que/quescripts.md
@@ -10,7 +10,7 @@ the job finishes.
In one terminal run the listener:
- que pub/notify --then "notify-send '\que' '\msg'"
+ que pub/notify --then "notify-send '{que}' '{msg}'"
In some other terminal run the job that takes forever:
@@ -23,9 +23,9 @@ Linux with title "`pub/notify`" and content "`tests are done`".
Que paths are multi-producer and multi-consumer, so you can add as many
terminals as you want.
-On macOS you could use:
+On macOS you could use something like this (just watch your quotes):
- osascript -e 'display notification "\msg" with title "\que"'
+ osascript -e "display notification \"{msg}\" with title \"{que}\""
in place of notify-send.
@@ -39,7 +39,7 @@ It's surprisingly easy to make a collaborative jukebox.
First start up a music player:
- que --poll pub/music --then "playsong '\msg'"
+ que --poll pub/music --then "playsong '{msg}'"
where `playsong` is a script that plays a file from data streaming to
`stdin`. For example [vlc](https://www.videolan.org/vlc/) does this when
diff --git a/Que/tutorial.md b/Que/tutorial.md
index 66ecd3c..6542ad3 100644
--- a/Que/tutorial.md
+++ b/Que/tutorial.md
@@ -50,4 +50,4 @@ To use other namespaces and add authentication/access controls, you can
Just reading and writing data isn't very exciting, so let's throw in
some events. We can very quickly put together a job processor.
- que pub/new-que --then "./worker.sh '\msg'"
+ que pub/new-que --then "./worker.sh '{msg}'"