This commit is contained in:
2025-07-24 19:17:55 -04:00
parent 689dded773
commit d6845e89d0

View File

@@ -6,9 +6,9 @@
#include "../core/standard.h" #include "../core/standard.h"
#include "contents.h" #include "contents.h"
#include "format.h" #include "format.h"
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <assert.h>
#include <getopt.h> #include <getopt.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
@@ -56,8 +56,7 @@
#define done #define done
#endif #endif
// int create_license_if_needed (format_t); int create_license_and_set_license_line (format_t, char **);
// int get_license_line_and_create_license (format_t, char **);
int create_configure (); int create_configure ();
int create_makefile (format_t); int create_makefile (format_t);
int create_project (format_t); int create_project (format_t);
@@ -212,35 +211,42 @@ sanitize (format_t *fmt)
return 0; return 0;
} }
// int int
// create_license_if_needed (format_t fmt) create_license_and_set_license_line (format_t fmt, char **license_line_buffer)
// { {
// char *license_line = NULL; if (fmt.licence == UNLICENCE)
// return get_license_line_and_create_license (fmt, &license_line); return 0;
// }
// reset_path;
// int /* TODO: Run better checks on licence_line_buffer to ensure we have enough space.
// get_license_line_and_create_license (format_t fmt, char This could be done through a multitude of ways; that is for you to figure out. */
// **license_line_buffer) assert (license_line_buffer != NULL);
// {
// switch (fmt.licence) // TODO: Remove this and actually implement the features.
// { #define TODO() \
// case BSD3: printfn ("Not impl"); \
// *license_line_buffer = "License BSD-3-Clause: BSD-3-Clause " assert (1 == 2)
// "<https://opensource.org/license/bsd-3-clause/>";
// return create_file_with_content ("COPYING", bsd3_license_template, switch (fmt.licence)
// YEAR, {
// fmt.name); case BSD3:
// TODO ();
// case GPLv3: break;
// default: case GPLv3:
// *license_line_buffer = "License GPLv3: GNU GPL version 3 " TODO ();
// "<https://www.gnu.org/licenses/gpl-3.0.html>"; break;
// return create_file_with_content ("COPYING", gplv3_license_template, case MIT:
// YEAR, TODO ();
// fmt.name); break;
// } // TODO: Replace fallthrough with unreachable macro for performace.
// } case UNLICENCE:
default:
printfn ("bad logic in create_licence_and_set_licence_line()");
return 1;
}
return 0;
}
int int
maybe_apply_clang_format (format_t fmt) maybe_apply_clang_format (format_t fmt)
@@ -369,19 +375,24 @@ parse_arguments (format_t *conf, int argc, char **argv)
break; break;
} }
} }
int positional_count = 0; int positional_count = 0;
for (int i = optind; i < argc; ++i) { for (int i = optind; i < argc; ++i)
if (argv[i][0] == '-') { {
fprintf(stderr, "Unknown flag: %s\n", argv[i]); if (argv[i][0] == '-')
continue; {
fprintf (stderr, "Unknown flag: %s\n", argv[i]);
continue;
} }
if (positional_count == 0) { if (positional_count == 0)
conf->project = argv[i]; {
} else if (positional_count == 1) { conf->project = argv[i];
conf->name = argv[i];
} }
positional_count++; else if (positional_count == 1)
{
conf->name = argv[i];
}
positional_count++;
} }
return 0; return 0;
} }