save
This commit is contained in:
20
src/flat.c
Normal file
20
src/flat.c
Normal file
@@ -0,0 +1,20 @@
|
||||
// SPDX-License-Identifer: BSD-3-Clause
|
||||
/*
|
||||
* A uemacs derided and inspired layout and format for smaller projects;
|
||||
* such as, a small library, or CLI.
|
||||
*/
|
||||
#include <lib/fs.h>
|
||||
#include <lib/say.h>
|
||||
|
||||
#include <template.h>
|
||||
#include "flat.h"
|
||||
|
||||
int generate_flat(char *package, char *author, int year, char *license,
|
||||
char *desc)
|
||||
{
|
||||
char *main;
|
||||
asprintf(&main, "%s.c", package);
|
||||
fs_write("Makefile", templ_flat_MAKEFILE, package);
|
||||
fs_write(main, templ_main, license);
|
||||
return 0;
|
||||
}
|
||||
8
src/flat.h
Normal file
8
src/flat.h
Normal file
@@ -0,0 +1,8 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#ifndef FLAT_H_
|
||||
#define FLAT_H_
|
||||
|
||||
int generate_flat(char *package, char *author, int year, char *license,
|
||||
char *desc);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#ifndef LICENCES_H
|
||||
#define LICENCES_H
|
||||
#ifndef LICENCES_H_
|
||||
#define LICENCES_H_
|
||||
|
||||
const char *fBSD = "\
|
||||
BSD 3-Clause License\n\
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#ifndef SHELL_H
|
||||
#define SHELL_H
|
||||
#ifndef SHELL_H_
|
||||
#define SHELL_H_
|
||||
|
||||
int write_shell(char *package, char *license, int year, char *author, char *m);
|
||||
|
||||
|
||||
32
src/yait.c
32
src/yait.c
@@ -3,7 +3,6 @@
|
||||
* Copyright (C) 2025, GCK.
|
||||
* Written by vx-clutch (vx-clutch)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
@@ -23,12 +22,14 @@
|
||||
|
||||
#include "shell.h"
|
||||
#include "license.h"
|
||||
#include <template.h>
|
||||
|
||||
typedef enum { MIT, GPL, BSD, UNL } license_t;
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{ "author", required_argument, 0, 'a' },
|
||||
{ "license", required_argument, 0, 'l' },
|
||||
{ "flat", no_argument, 0, 'f' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -96,6 +97,7 @@ int main(int argc, char **argv)
|
||||
int lose = 0;
|
||||
char *m = str_dup("Does a thing"), *package;
|
||||
bool shell = false;
|
||||
bool flat = false;
|
||||
char *author = get_name();
|
||||
exit_status = EXIT_SUCCESS;
|
||||
int year = get_year();
|
||||
@@ -147,6 +149,9 @@ int main(int argc, char **argv)
|
||||
case 'S':
|
||||
shell = true;
|
||||
break;
|
||||
case 'f':
|
||||
flat = true;
|
||||
break;
|
||||
default:
|
||||
lose = 1;
|
||||
}
|
||||
@@ -175,9 +180,30 @@ int main(int argc, char **argv)
|
||||
if (chdir(project_dir))
|
||||
fatalfa(errno);
|
||||
|
||||
switch (license) {
|
||||
case MIT:
|
||||
fs_write("COPYING", fMIT, year, author);
|
||||
break;
|
||||
case GPL:
|
||||
fs_write("COPYING", fGPL);
|
||||
break;
|
||||
case BSD:
|
||||
fs_write("COPYING", fBSD, year, author);
|
||||
break;
|
||||
case UNL:
|
||||
default:
|
||||
fs_write("COPYING", fUNL);
|
||||
}
|
||||
|
||||
fs_write("README", templ_README, author, package, package, m, year,
|
||||
author, author, package);
|
||||
fs_write("README-dev", templ_README_dev, year, author);
|
||||
package, author, package);
|
||||
|
||||
if (flat)
|
||||
exit_status =
|
||||
generate_flat(package, author, year, license_str, m);
|
||||
else
|
||||
exit_status =
|
||||
generate_regular(package, author, year, license_str, m);
|
||||
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user