about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSebastian Wiesner <sebastian@swsnr.de>2020-04-11 22:25:16 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-04-11 22:39:41 +0200
commitb11f60c3e9dd69d2a113611300defe1ac2bc7008 (patch)
treec7fc4d5d1439c013cb92903603b5f28fb8b452bc
parentb495a315d536d7c118283aa57b8a406cec50ccbb (diff)
downloadwcal-b11f60c3e9dd69d2a113611300defe1ac2bc7008.tar.gz
wcal-b11f60c3e9dd69d2a113611300defe1ac2bc7008.tar.xz
wcal-b11f60c3e9dd69d2a113611300defe1ac2bc7008.zip
add -C to force color output
Closes: #1 [via git-merge-pr]
-rw-r--r--wcal.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/wcal.c b/wcal.c
index ecf4abc..4a46b8f 100644
--- a/wcal.c
+++ b/wcal.c
@@ -22,7 +22,7 @@
 #include <time.h>
 #include <unistd.h>
 
-int flag1, flag3, flagc, flagi, flagy;
+int flag1, flag3, flagc, flagC, flagi, flagy;
 
 void
 parse_isodate(char *optarg, struct tm *tm)
@@ -60,11 +60,12 @@ main(int argc, char *argv[])
 	struct tm *tm = gmtime(&now);
 
 	int c;
-	while ((c = getopt(argc, argv, "13cid:y")) != -1)
+	while ((c = getopt(argc, argv, "13cCid:y")) != -1)
 		switch (c) {
 		case '1': flag1 = 1; break;
 		case '3': flag3 = 1; break;
 		case 'c': flagc = 1; break;
+		case 'C': flagC = 1; break;
 		case 'y': flagy = 1; break;
 		case 'i': flagi = 1; break;
 		case 'd': parse_isodate(optarg, tm); break;
@@ -98,7 +99,7 @@ main(int argc, char *argv[])
 		mktime(tm);
 	}
 
-	int color = isatty(1);
+	int color = isatty(1) || flagC;
 
 	printf("        %sMo Tu We Th Fr Sa Su%s\n",
 	    color ? "\e[4m" : "",