This commit is contained in:
2025-11-11 21:49:23 -05:00
parent 22242dc532
commit f764bc6759
9 changed files with 140 additions and 47 deletions

60
main.c
View File

@@ -18,61 +18,63 @@
#include <stdlib.h>
#include <string.h>
#include "edef.h"
#include "globals.h"
#include "proj.h"
#include "shell.h"
#include "usage.h"
#include "version.h"
void usage(int status)
{
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(" -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 main(int argc, char **argv) {
int shell_mode = 0;
char *package = NULL;
int carg;
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 (argc == 2) {
if (strcmp(argv[1], "--help") == 0)
usage(EXIT_SUCCESS);
else if (strcmp(argv[1], "--version") == 0) {
version();
exit(EXIT_SUCCESS);
}
}
for (carg = 1; carg < argc; ++carg) {
if (argv[carg][0] == '-') {
if (argv[carg][1] == 's')
shell_mode = SINGLE;
else if (argv[carg][1] == 'S')
shell_mode = FULL;
else if (argv[carg][1] == 'i')
I = 1;
else
die("unknown option");
} else
package = argv[carg];
}
if (!package)
die("no package name provided");
if (I)
puts("'i' is not implemented yet");
if (shell_mode)
makeshell(package, shell_mode);
else