aboutsummaryrefslogtreecommitdiffstats
path: root/src/0001-Added-support-for-long-arguments.patch
blob: aa0d590eddf17ba4b9fab850827cd55b82746253 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From ac0d9ae25dd487f7cafbda8152753dfe09696399 Mon Sep 17 00:00:00 2001
From: lovelace <lovelace@kinl.gq>
Date: Wed, 27 Oct 2021 00:59:09 +0000
Subject: [PATCH] Added support for long arguments

---
 src/main.c | 32 ++++++++++++++++++++++----------
 1 file 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':
-- 
2.33.1