ref: 5b0cf2e6a0ed85420a471a48c43a253e931237a4
parent: 8d24acf30776c1bee6b09af285d417bc66d87953
author: Julien Blanchard <jblanchard@makemusic.com>
date: Fri Apr 14 09:00:08 EDT 2023
Add abbreviated commands
--- a/README.md
+++ b/README.md
@@ -1,12 +1,53 @@
# masto9
-## Token
+A mastodon client for 9front.
-echo 'proto=pass service=mastodon server=instanceHostName pass=yourToken user=julienxx' > /mnt/factotum/ctl
+## Usage
-## Plumbing rules
+`masto9 DOMAIN [COMMAND] [DATA]`
+Available commands:
+
+- `toot 'TEXT'` to post a new textual toot. Abbrev `t`
+- `tootwithfile ['TEXT'] FILEPATH` to post a new toot with a file and optional text. . Abbrev `tf`
+- `reply ID` to reply to a toot. Abbrev `r`
+- `notifications` to view your notifications. Abbrev `n`
+- `mentions` to view your mentions. Abbrev `m`
+- `fav|unfav|boost|unboost ID` to act on a toot. Abbrev `f|uf|b|ub`
+- `more ID` to view the timeline starting from a toot
+- `debug ID` to view a toot JSON
+
+if no COMMAND is provided masto9 defaults to reading your timeline.
+
+### Installation
+
+Clone the repo, `mk install`.
+
+### Token
+
+You will need to create a token for your account https://docs.joinmastodon.org/client/token/ and add it to factotum:
+
+```
+echo 'proto=pass service=mastodon server=INSTANCE_HOSTNAME pass=TOKEN user=USERNAME' > /mnt/factotum/ctl
+```
+
+### Plumbing rules
+
+For convenience add some plumb rules to `$home/lib/plumbing` right before `include basic` line:
+
+```
type is text
data matches 'Favorite\[([0-9]+)\]'
-plumb to toot_reply
-plumb client window masto9 hostname fav $1 && read
+plumb to mastodon
+plumb client window masto9 DOMAIN fav $1 && read
+
+type is text
+data matches 'Boost\[([0-9]+)\]'
+plumb to mastodon
+plumb client window masto9 DOMAIN boost $1 && read
+
+type is text
+data matches 'Reply\[([0-9]+)\]'
+plumb to mastodon
+plumb client window masto9 DOMAIN reply $1
+```
--- a/masto9.c
+++ b/masto9.c
@@ -343,7 +343,7 @@
void
usage(void)
{
- sysfatal("usage: masto9 url");
+ sysfatal("usage: masto9 DOMAIN [COMMAND] [DATA]");
}
void
@@ -446,10 +446,11 @@
Toot toots[TOOTSCOUNT];
gethome(token, host, toots, nil);
displaytoots(toots, host);
- } else if(strcmp(command, "toot") == 0) {
+ } else if(strcmp(command, "toot") == 0 || strcmp(command, "t") == 0) {
text = argv[3];
posttoot(token, host, text);
- } else if(strcmp(command, "tootfile") == 0) {
+ } else if(strcmp(command, "tootwithfile") == 0 ||
+ strcmp(command, "tf") == 0) {
if(argc > 4) {
text = argv[3];
filepath = argv[4];
@@ -458,19 +459,19 @@
filepath = argv[3];
}
postattachment(token, host, text, filepath);
- } else if(strcmp(command, "fav") == 0) {
+ } else if(strcmp(command, "fav") == 0 || strcmp(command, "f") == 0) {
id = argv[3];
fav(token, host, id);
- } else if(strcmp(command, "unfav") == 0) {
+ } else if(strcmp(command, "unfav") == 0 || strcmp(command, "uf") == 0) {
id = argv[3];
unfav(token, host, id);
- } else if(strcmp(command, "boost") == 0) {
+ } else if(strcmp(command, "boost") == 0 || strcmp(command, "b") == 0) {
id = argv[3];
boost(token, host, id);
- } else if(strcmp(command, "unboost") == 0) {
+ } else if(strcmp(command, "unboost") == 0 || strcmp(command, "ub") == 0) {
id = argv[3];
unboost(token, host, id);
- } else if(strcmp(command, "reply") == 0) {
+ } else if(strcmp(command, "reply") == 0 || strcmp(command, "r") == 0) {
id = argv[3];
reply(token, host, id);
} else if(strcmp(command, "debug") == 0) {
@@ -481,14 +482,18 @@
Toot toots[TOOTSCOUNT];
gethome(token, host, toots, id);
displaytoots(toots, host);
- } else if(strcmp(command, "notifications") == 0) {
+ } else if(strcmp(command, "notifications") == 0 ||
+ strcmp(command, "n") == 0) {
Notification notifs[NOTIFSCOUNT];
getnotifications(token, host, notifs, "");
displaynotifications(notifs);
- } else if(strcmp(command, "mentions") == 0) {
+ } else if(strcmp(command, "mentions") == 0 || strcmp(command, "m") == 0) {
Notification notifs[NOTIFSCOUNT];
getnotifications(token, host, notifs, "mention");
displaynotifications(notifs);
+ } else {
+ print("Unknown command %s.\n", command);
+ usage();
}
free(p);