Add `install` command to make and update -h output
[sigilutils.git] / sigutils.c
blobcbffa3272bf327c62e3ca7656319d70f72e06974
2 #include "basics.h"
3 #include "numbers.h"
4 #include "squares.h"
5 #include <unistd.h>
7 #define VERSION 0.01
9 char name[] = "Sigil Utilities, version";
10 char contact[] = "(C) 2020 theblaqcksquid <theblacksquid@subvertising.org>\n";
11 char license[] = "Licensed under GNU GPL v3\n";
13 char help0[] = "usage: sigutils [options] <STATEMENT OF INTENT>\n";
14 char help1[] = "-h Print this message and quit.\n";
15 char help2[] = "-v Print the version and license info, then quit.\n";
16 char help3[] = "-n Append the numerical and root values to the result.\n";
17 char help4[] = "-w Generate a Word Square based on the SOI\n";
19 int main(int argc, char** argv)
21 int numeric_flag = 0;
22 int version_flag = 0;
23 int help_flag = 0;
24 int word_flag = 0;
25 int c;
27 while ((c = getopt(argc, argv, "nvhw")) != -1)
28 switch (c)
30 case 'n': numeric_flag = 1;
31 break;
33 case 'v': version_flag = 1;
34 break;
36 case 'h': help_flag = 1;
37 break;
39 case 'w': word_flag = 1;
40 break;
44 if (version_flag)
46 printf("%s %.2f\n%s%s", name, VERSION, contact, license);
47 return 0;
50 else if (help_flag)
52 printf("%s%s%s%s%s", help0, help1, help2, help3, help4);
53 return 0;
56 char* raw = absorb_words(argc, argv, optind);
57 char* result = string_process(raw);
59 printf("%s", result);
61 if (numeric_flag)
63 int value = string_value(result, LETTERS);
64 int root = digital_root(value, 10);
65 printf(" %d %d", value, root);
68 if (word_flag)
70 printf("\n\n%s", generate_square(result));
73 printf("\n");
75 free(result);
76 free(raw);
77 return 0;