minor cleanup and usability improvement

This commit is contained in:
Valerie Wolfe 2024-07-09 14:00:38 -04:00
parent bcc61365e1
commit 2960c47176
3 changed files with 14 additions and 17 deletions

View file

@ -1,7 +1,5 @@
#include "basic.h" #include "basic.h"
#include <stdio.h>
#include "draw.h" #include "draw.h"
void rainbow_8() { void rainbow_8() {

2
full.c
View file

@ -1,7 +1,5 @@
#include "full.h" #include "full.h"
#include <stdio.h>
#include "draw.h" #include "draw.h"
void rainbow_256() { void rainbow_256() {

27
main.c
View file

@ -2,11 +2,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "draw.h"
#include "basic.h" #include "basic.h"
#include "full.h" #include "full.h"
#define VERSION "0.0.3" #define VERSION "0.0.4"
#define RESET "\x1b[0m" #define RESET "\x1b[0m"
@ -34,11 +33,11 @@ void help() {
); );
} }
unsigned long djb_hash(unsigned char *string) { unsigned long djb_hash(char *string) {
unsigned long output = 5381; unsigned long output = 5381;
int c; int c;
while(c = *string++) while((c = *string++))
output = ((output << 5) + output) + c; output = ((output << 5) + output) + c;
return output; return output;
@ -55,15 +54,6 @@ int main(int argc, char **argv) {
if(colorterm != NULL && strcmp(colorterm, "")) if(colorterm != NULL && strcmp(colorterm, ""))
color_mode = 1; color_mode = 1;
// handle flags
if(strcmp(flag, "--version") == 0) {
version();
return 0;
} else if(strcmp(flag, "--help") == 0) {
help();
return 0;
}
unsigned long flag_hash = djb_hash(flag); unsigned long flag_hash = djb_hash(flag);
char *output; char *output;
@ -124,6 +114,17 @@ int main(int argc, char **argv) {
else transgender_8(); else transgender_8();
break; break;
// handle flags, but in the command-line sense
case 6951207451432lu: // --help
case 5861498lu: // -h
help();
break;
case 249805560270004805lu: // --version
case 5861512lu: // -v
version();
break;
default: default:
printf("pride-c: no flag '%s' found.", flag); printf("pride-c: no flag '%s' found.", flag);
return 1; return 1;