Files
yait/main.c
2025-11-09 21:55:07 -05:00

75 lines
1.4 KiB
C

/*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "shell.h"
#include "usage.h"
#include "version.h"
#include "proj.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(" --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 c = 0;
int S = 0;
int carg;
if (argc == 2) {
if (strcmp(argv[1], "--help") == 0) {
usage(EXIT_FAILURE);
}
if (strcmp(argv[1], "--version") == 0) {
version();
exit(EXIT_SUCCESS);
}
}
for (carg = 0; carg < argc; ++carg) {
if (argv[carg][0] == '-') {
switch (argv[carg][1]) {
case 'S':
S = 1;
break;
}
}
}
if (argc < 2 || c)
die("not enough arguments");
char *package = argv[carg - 1];
if (S)
makeshell(package);
else
makeproj(package);
return 0;
}