summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-27 09:51:39 +0200
committerdefault <nobody@localhost>2022-09-27 09:51:39 +0200
commit55226d3e6b2e468a13b17994fa8564604104dc30 (patch)
tree0bde94b1076eecaa8b8e5519014e9d18c174ed2a /main.c
parent26a3b260d56cedf0ca56b331d8bec71d1a8b49f8 (diff)
Started command-line command 'note'.
Diffstat (limited to 'main.c')
-rw-r--r--main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/main.c b/main.c
index 4fd0a87..4b965b3 100644
--- a/main.c
+++ b/main.c
@@ -2,6 +2,7 @@
/* copyright (c) 2022 grunfink - MIT license */
#include "xs.h"
+#include "xs_io.h"
#include "xs_encdec.h"
#include "xs_json.h"
@@ -34,6 +35,7 @@ int usage(void)
printf("request {basedir} {uid} {url} Requests an object\n");
printf("actor {basedir} {uid} {url} Requests an actor\n");
+ printf("note {basedir} {uid} {'text'} Sends a note to followers\n");
return 1;
}
@@ -161,6 +163,39 @@ int main(int argc, char *argv[])
return 0;
}
+ if (strcmp(cmd, "note") == 0) {
+ int status;
+ xs *data = NULL;
+ xs *content = NULL;
+ xs *f_content = NULL;
+
+ if (strcmp(url, "-") == 0) {
+ /* get the content from an editor */
+ FILE *f;
+
+ system("$EDITOR /tmp/snac-edit.txt");
+
+ if ((f = fopen("/tmp/snac-edit.txt", "r")) != NULL) {
+ content = xs_readall(f);
+ fclose(f);
+
+ unlink("/tmp/snac-edit.txt");
+ }
+ else {
+ printf("Nothing to send\n");
+ return 1;
+ }
+ }
+ else
+ content = xs_dup(url);
+
+ not_really_markdown(content, &f_content);
+
+ printf("%s\n", f_content);
+
+ return 0;
+ }
+
return 0;
}