83 lines
1.9 KiB
C
83 lines
1.9 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 "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(" -i ignore estruct.h and prompt for all\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 i = 0;
|
|
int shell_mode = 0;
|
|
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)
|
|
shell_mode = SINGLE;
|
|
else if (strcmp(argv[i], "-S") == 0)
|
|
shell_mode = FULL;
|
|
else if (strcmp(argv[i], "-i") == 0)
|
|
i = 1;
|
|
else
|
|
die("unknown option");
|
|
}
|
|
else
|
|
package = argv[i];
|
|
}
|
|
|
|
if (!package)
|
|
die("no package name provided");
|
|
|
|
if (shell_mode)
|
|
makeshell(package, shell_mode);
|
|
else
|
|
makeproj(package);
|
|
|
|
return 0;
|
|
}
|