Use puts() for the version and help messages.
[sigilutils.git] / sigutils.c
blobb5ce9d95d0f75bacce6f50b07743349c32a976ed
2 #include "basics.h"
3 #include "numbers.h"
4 #include "squares.h"
5 #include <unistd.h>
7 #define VERSION 0.01
9 void version_msg ()
11 puts("Sigil Utilities, version 0.01\n"
12 "(C) 2020 theblaqcksquid <theblacksquid@subvertising.org>\n"
13 "Licensed under GNU GPL v3\n");
16 void help_msg ()
18 puts("usage: sigutils [options] <STATEMENT OF INTENT>\n"
19 "-h Print this message and quit.\n"
20 "-v Print the version and license info then quit.\n"
21 "-n Append the numerical and root values to the result.\n"
22 "-w Generate a Word Square based on the SOI\n"
23 "-W Generate word square ONLY.\n");
26 int main(int argc, char** argv)
28 int numeric_flag = 0;
29 int version_flag = 0;
30 int help_flag = 0;
31 int word_flag = 0;
32 int word_only_flag = 0;
33 int c;
35 while ((c = getopt(argc, argv, "nvhwW")) != -1)
36 switch (c)
38 case 'n': numeric_flag = 1;
39 break;
41 case 'v': version_flag = 1;
42 break;
44 case 'h': help_flag = 1;
45 break;
47 case 'w': word_flag = 1;
48 break;
50 case 'W': word_only_flag = 1;
51 break;
54 if (version_flag)
56 version_msg();
57 return 0;
60 else if (help_flag)
62 help_msg();
63 return 0;
66 char* raw = absorb_words(argc, argv, optind);
67 char* result = string_process(raw);
69 if (!word_only_flag)
70 printf("%s", result);
72 if (numeric_flag)
74 int value = string_value(result, LETTERS);
75 int root = digital_root(value, 10);
76 printf(" %d %d", value, root);
79 if (word_flag || word_only_flag)
81 if (!word_only_flag)
82 printf("\n\n");
83 printf("%s", generate_square(result));
86 printf("\n");
88 free(result);
89 free(raw);
90 return 0;