aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2021-10-14 18:57:52 +0200
committerqorg11 <qorg@vxempire.xyz>2021-10-14 18:57:52 +0200
commit6401a6972d654a25904c2c88d121fa22d9636279 (patch)
tree9a75e21dc72c222ac2794feb11bda3e3274cb2bc
parent3d9c9ac7a40f202d5f0577ce24e18e5eb6799688 (diff)
downloaddemiurge-6401a6972d654a25904c2c88d121fa22d9636279.tar.gz
demiurge-6401a6972d654a25904c2c88d121fa22d9636279.zip
Added help message and printable usage message (-h and -u flags)
-rw-r--r--readme.org10
-rw-r--r--src/main.c31
2 files changed, 38 insertions, 3 deletions
diff --git a/readme.org b/readme.org
index 8ee20c0..ded17fc 100644
--- a/readme.org
+++ b/readme.org
@@ -19,7 +19,15 @@
# all jpgs files in different statuses
cat /etc/passwd | ./demiurge # Posts the output of /etc/passwd
#+end_src
-
+
+ demiurge is a tool to make fedi bots using shell scripts rather
+ than a client you'd use. For example:
+
+ #+begin_src shell
+ export x=$(curl https://some-website.tld)
+ ./demiurge -s "current weather: $x"
+ #+end_src
+
** TODO:
Check timeline and notifications, replies...
diff --git a/src/main.c b/src/main.c
index 6c01949..4f30290 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,6 +38,19 @@ usage(const char *progname)
return;
}
+void
+help()
+{
+ puts("-s: status to post");
+ puts("-F: filename to be attatched with the post");
+ puts("-v: The visibility which the post will have, can be: public, "
+ "unlisted, private and direct");
+ puts("-f: Follow an account");
+ puts("-u: Unfollow an account");
+ puts("-U: prints usage message");
+ puts("-h: prints this help message");
+}
+
/* prints a string to stderr */
int
@@ -56,7 +69,7 @@ main(int argc, char **argv)
if(!isatty(0)) {
eputs("Not a terminal, reading from stdin");
char status[5000]; /* TODO get max from instance */
- fread(status,5000,1,stdin);
+ fread(status, 5000, 1, stdin);
post_status(status, NULL, NULL);
return 0;
}
@@ -66,7 +79,7 @@ main(int argc, char **argv)
return -1;
}
- while((c = getopt(argc, argv, "s:v:F:f:u:")) != -1) {
+ while((c = getopt(argc, argv, "s:v:F:f:u:hU")) != -1) {
switch(c) {
case 's':
status = optarg;
@@ -91,6 +104,20 @@ main(int argc, char **argv)
free(account_id);
}
return 0;
+ case 'h':
+ help();
+ return 0;
+ break;
+ case 'U':
+ usage(argv[0]);
+ return 0;
+ break;
+ case '?':
+ break;
+ default:
+ fprintf(stderr, "Unrecognized option: %c\n", c);
+ return 0;
+ break;
}
}