aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlovelace <lovelace@kinl.gq>2021-10-27 00:59:09 +0000
committerqorg11 <qorg@vxempire.xyz>2021-10-27 03:07:14 +0200
commit8309515c96f75124a718fb8ed599353d5804e2f7 (patch)
treecc7a6d0a06fff5e0345f9754ed179f861dba2bfd
parentd76209a76c6cdf60c0f6d339d4df28fd99d9f21d (diff)
downloaddemiurge-8309515c96f75124a718fb8ed599353d5804e2f7.tar.gz
demiurge-8309515c96f75124a718fb8ed599353d5804e2f7.zip
Added support for long arguments
-rw-r--r--src/main.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 4f30290..097fc51 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,14 +41,14 @@ usage(const char *progname)
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");
+ puts("-s, --status: status to post");
+ puts("-F, --filename: filename to be attatched with the post");
+ puts("-v, --visibility: The visibility which the post will have, can"
+ "be: public unlisted, private and direct");
+ puts("-f, --follow: Follow an account");
+ puts("-u, --unfollow: Unfollow an account");
+ puts("-U, --usage: prints usage message");
+ puts("-h, --help: prints this help message");
}
/* prints a string to stderr */
@@ -79,9 +79,21 @@ main(int argc, char **argv)
return -1;
}
- while((c = getopt(argc, argv, "s:v:F:f:u:hU")) != -1) {
+ int option_index = 0;
+ static struct option long_options[] = {
+ {"status", required_argument, 0, 's'},
+ {"filename", required_argument, 0, 'F'},
+ {"visibility", required_argument, 0, 'v'},
+ {"follow", required_argument, 0, 'f'},
+ {"unfollow", required_argument, 0, 'u'},
+ {"usage", no_argument, 0, 'U'},
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while((c = getopt_long(argc, argv, "s:v:F:f:u:hU", long_options, &option_index)) != -1) {
switch(c) {
- case 's':
+ case 's':
status = optarg;
break;
case 'v':