save
This commit is contained in:
BIN
c-out/bin/yait
BIN
c-out/bin/yait
Binary file not shown.
BIN
c-out/obj/main.o
BIN
c-out/obj/main.o
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
PREFIX=/usr/bin/
|
||||
CFLAGS=-Wall -Wextra -g
|
||||
LDFLAGS=
|
||||
CC=clang
|
||||
@@ -19,8 +19,10 @@ parse_standard_options (void (*usage) (int), int argc, char **argv)
|
||||
}
|
||||
else if (strcmp (argv[i], "--version") == 0)
|
||||
{
|
||||
printf ("%s %s %d\nCopyright (C) %d %s.\n%s\nThis is free software: "
|
||||
"you are free to change and redistribute it.\nThere is NO "
|
||||
printf ("%s %s %d\nCopyright (C) %d %s.\n%s\nThis is "
|
||||
"free software: "
|
||||
"you are free to change and redistribute "
|
||||
"it.\nThere is NO "
|
||||
"WARRNTY, to the extent permitted by law.\n",
|
||||
PROGRAM, VERSION, COMMIT, YEAR, AUTHORS, LICENSE_LINE);
|
||||
exit (EXIT_SUCCESS);
|
||||
|
||||
45
yait/main.c
45
yait/main.c
@@ -24,12 +24,22 @@
|
||||
#define print_option(option, description) \
|
||||
printf (" %-20s %-20s\n", option, description)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define on_error(msg, code) \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "\n"); \
|
||||
printfn (msg ": %s", strerror (err)); \
|
||||
return code; \
|
||||
}
|
||||
#else
|
||||
#define on_error(msg, code) \
|
||||
if (err) \
|
||||
{ \
|
||||
printfn (msg ": %s", strerror (err)); \
|
||||
return code; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define debug(fmt, ...) \
|
||||
@@ -84,25 +94,27 @@ usage (int status)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printfn ("error: not enough arguments.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int status = initialize_main (&argc, &argv);
|
||||
status = parse_standard_options (usage, argc, argv);
|
||||
err = initialize_main (&argc, &argv);
|
||||
err = parse_standard_options (usage, argc, argv);
|
||||
|
||||
if (status && status != HELP_REQUESTED)
|
||||
if (err && err != HELP_REQUESTED)
|
||||
{
|
||||
printfn ("error: %s", strerror (status));
|
||||
return status;
|
||||
printfn ("error: %s", strerror (err));
|
||||
return err;
|
||||
}
|
||||
|
||||
format_t conf = { 0 };
|
||||
|
||||
conf.project = argv[0]; // fix: project name is argv[1]
|
||||
conf.name = (argc > 1) ? argv[1] : NULL; // fix: name is optional, at argv[2]
|
||||
conf.project = argv[0];
|
||||
conf.name = (argc > 1) ? argv[1] : NULL;
|
||||
|
||||
if (!conf.name)
|
||||
{
|
||||
@@ -114,7 +126,11 @@ main (int argc, char **argv)
|
||||
conf.flag.clang_format = DEFAULT_CLANG_FORMAT;
|
||||
conf.licence = DEFAULT_LICENSE;
|
||||
|
||||
return create_project (conf);
|
||||
err = create_project (conf);
|
||||
if (!err) debug ("project made successfully");
|
||||
else debug ("something when wrong");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -122,16 +138,16 @@ create_project (format_t fmt)
|
||||
{
|
||||
int err;
|
||||
|
||||
debugc ("sanitize... ");
|
||||
debugc ("sanitize");
|
||||
err = sanitize (&fmt);
|
||||
on_error ("failed to sanitize format", err);
|
||||
done;
|
||||
|
||||
debugc ("take %s", fmt.project);
|
||||
err = create_and_enter_directory (fmt.project);
|
||||
depth = 0;
|
||||
on_error ("failed to create or enter directory", err);
|
||||
done;
|
||||
depth = 0;
|
||||
|
||||
// debug ("create licenseing");
|
||||
// err = create_license_if_needed (fmt);
|
||||
@@ -172,8 +188,17 @@ reset_path_ ()
|
||||
int
|
||||
sanitize (format_t *fmt)
|
||||
{
|
||||
if (!fmt->project)
|
||||
fmt->project = DEFAULT_PROJECT_NAME;
|
||||
if (!fmt->name)
|
||||
fmt->name = DEFAULT_USER_NAME;
|
||||
if (fmt->licence != BSD3 && fmt->licence != GPLv3 && fmt->licence != MIT)
|
||||
fmt->licence = DEFAULT_LICENSE;
|
||||
fmt->flag.git = fmt->flag.git ? true : DEFAULT_GIT_INIT;
|
||||
fmt->flag.clang_format
|
||||
= fmt->flag.clang_format ? true : DEFAULT_CLANG_FORMAT;
|
||||
fmt->flag.GNU = fmt->flag.GNU ? true : false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user