pride-c/main.c
2024-03-23 12:20:38 -04:00

127 lines
2.1 KiB
C

#include <stdio.h>
#define VERSION "0.0.1"
#define ANSI "\x1b[38;5;"
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define GRAY 7
#define L_BLACK 8
#define L_RED 9
#define L_GREEN 10
#define L_YELLOW 11
#define L_BLUE 12
#define L_MAGENTA 13
#define L_CYAN 14
#define WHITE 15
#define RESET "\x1b[0m"
#define STRIPE "█████████████████\n"
void version() {
printf("pride-c min v" VERSION "\n");
}
void help() {
version();
printf(
"Valerie Wolfe <sleeplessval@gmail.com>\n"
"Display 8-color pride flags in the terminal.\n\n"
"usage: pride [symbol]\n\n"
"symbols:\n"
" l lesbian flag\n"
" g gay flag\n"
" b bisexual flag\n"
" t transgender flag\n"
" n nonbinary flag\n"
" p pansexual flag\n"
" r rainbow flag\n"
" h help text\n"
" v version text\n"
);
}
void stripe(const unsigned short int color) {
printf(ANSI "%dm" STRIPE, color);
}
int main(int argc, char **argv) {
// get argv[1] or fall back to RAINBOW
char sym;
if(argc > 1) { sym = argv[1][0]; }
else { sym = 'r'; }
switch(sym) {
case 'b': // - BISEXUAL -
stripe(RED);
stripe(MAGENTA);
stripe(BLUE);
break;
case 'h': // - HELP TEXT -
help();
break;
case 'g': // - GAY -
stripe(CYAN);
stripe(L_CYAN);
stripe(WHITE);
stripe(L_BLUE);
stripe(BLUE);
break;
case 'l': // - LESBIAN -
stripe(RED);
stripe(L_RED);
stripe(WHITE);
stripe(L_MAGENTA);
stripe(MAGENTA);
break;
case 'n': // - NON-BINARY -
stripe(L_YELLOW);
stripe(WHITE);
stripe(MAGENTA);
stripe(BLACK);
break;
case 'p': // - PANSEXUAL -
stripe(MAGENTA);
stripe(L_YELLOW);
stripe(CYAN);
break;
case 'r': // - RAINBOW -
stripe(RED);
stripe(L_RED);
stripe(L_YELLOW);
stripe(GREEN);
stripe(BLUE);
stripe(MAGENTA);
break;
case 't': // - TRANSGENDER -
stripe(L_CYAN);
stripe(L_MAGENTA);
stripe(WHITE);
stripe(L_MAGENTA);
stripe(L_CYAN);
break;
default:
printf("pride-c: no flag '%c' found", sym);
break;
}
printf(RESET);
return 0;
}