This commit is contained in:
2025-11-10 21:54:10 -05:00
parent bfefb223f1
commit 1c9d62dabf
10 changed files with 172 additions and 41 deletions

65
main.c
View File

@@ -18,16 +18,18 @@
#include <stdlib.h>
#include <string.h>
#include "globals.h"
#include "proj.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(" -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);
@@ -36,37 +38,44 @@ void usage(int status)
int main(int argc, char **argv)
{
int c = 0;
int S = 0;
int carg;
int mode = -1;
char *package = NULL;
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)
if (argc < 2)
die("not enough arguments");
char *package = argv[carg - 1];
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 (S)
makeshell(package);
if (!package)
die("no package name provided");
if (S == SINGLE || S == FULL)
makeshell(package, mode);
else
makeproj(package);