/* * main.c * * yait/fSD 1.0 * * Copying policy: * * yait 1.0 can be copied and distributed freely for any * non-commercial purposes. yait 1.0 can only be incorporated * into commercial software with the permission of the current author. * * This file contains the main driving routine, and some handling * for C/SH distinction. * */ #include #include #include #include "globals.h" #include "proj.h" #include "shell.h" #include "usage.h" #include "version.h" void usage(int status) { printf("Usage: %s filename\n", PROGRAM_NAME); printf(" or: %s [options]\n\n", PROGRAM_NAME); fputs(" -s enable shell creation mode\n", stdout); fputs(" -S enable shell creation mode as a full project\n", stdout); fputs(" --help display this help and exit\n", stdout); fputs(" --version output version information and exit\n", stdout); exit(status); } int main(int argc, char **argv) { int S = 0; int mode = -1; char *package = NULL; if (argc < 2) die("not enough arguments"); for (int i = 1; i < argc; ++i) { if (argv[i][0] == '-') { if (strcmp(argv[i], "--help") == 0) usage(EXIT_SUCCESS); else if (strcmp(argv[i], "--version") == 0) { version(); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-s") == 0) { S = 1; mode = SINGLE; } else if (strcmp(argv[i], "-S") == 0) { S = 1; mode = FULL; } else die("unknown option"); } else package = argv[i]; } if (!package) die("no package name provided"); if (S == SINGLE || S == FULL) makeshell(package, mode); else makeproj(package); return 0; }