save
This commit is contained in:
470
yait/contents.h
470
yait/contents.h
@@ -1,272 +1,264 @@
|
|||||||
|
// clang-format off
|
||||||
#ifndef CONTENTS_H
|
#ifndef CONTENTS_H
|
||||||
#define CONTENTS_H
|
#define CONTENTS_H
|
||||||
|
|
||||||
#define line(l) l "\n"
|
#define line(l) l "\n"
|
||||||
|
|
||||||
/* README template */
|
/* README template */
|
||||||
char *readme_template = line ("%s ( concise description )") line () line (
|
char *readme_template =
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
line ("%s ( concise description )")
|
||||||
"tempor") line ("incididunt ut labore et dolore magna aliqua. Ut enim ad "
|
line ()
|
||||||
"minim veniam, quis")
|
line ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor")
|
||||||
line ("nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
|
line ("incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis")
|
||||||
"consequat.") line ("Duis aute irure dolor in reprehenderit in "
|
line ("nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.")
|
||||||
"voluptate velit esse cillum dolore eu")
|
line ("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu")
|
||||||
line ("fugiat nulla pariatur. Excepteur sint occaecat cupidatat non "
|
line ("fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in")
|
||||||
"proident, sunt in")
|
line ("culpa qui officia deserunt mollit anim id est laborum.");
|
||||||
line ("culpa qui officia deserunt mollit anim id est laborum.");
|
|
||||||
|
|
||||||
/* configure script template */
|
/* configure script template */
|
||||||
char *configure_template = line ("#!/bin/sh") line () line ("usage() {") line (
|
char *configure_template =
|
||||||
"cat <<EOF") line ("Usage: $0 [OPTION]... [VAR=VALUE]...") line ()
|
line ("#!/bin/sh")
|
||||||
line ("To assign environment variables (e.g., CC, CFLAGS...), specify "
|
line ()
|
||||||
"them as") line ("VAR=VALUE.") line ()
|
line ("usage() {")
|
||||||
line (" CC C compiler command [detected]") line (
|
line ("cat <<EOF")
|
||||||
" CFLAGS C "
|
line ("Usage: $0 [OPTION]... [VAR=VALUE]...")
|
||||||
"compiler flags [-g, "
|
line ()
|
||||||
"...]") line () line ("EOF") line ("exit 0") line ("}") line ()
|
line ("To assign environment variables (e.g., CC, CFLAGS...), specify them as")
|
||||||
line ("echo () { printf \"%%s\\n\" \"$*\" ; }") line (
|
line ("VAR=VALUE.")
|
||||||
"cmdexists () { "
|
line ()
|
||||||
"type \"$1\" "
|
line (" CC C compiler command [detected]")
|
||||||
">/dev/null 2>&1 "
|
line (" CFLAGS C compiler flags [-g, ...]")
|
||||||
"; }") line ("trycc () { test -z \"$CC\" && cmdexists \"$1\" "
|
line ()
|
||||||
"&& CC=$1 ; "
|
line ("EOF")
|
||||||
"}") line () line ("prefix=/usr/bin/")
|
line ("exit 0")
|
||||||
line ("CFLAGS=\"-Wall -Wextra -O2\"") line ("LDFLAGS=") line (
|
line ("}")
|
||||||
"CC=") line () line ("for arg ; do") line ("case \"$arg\" "
|
line ()
|
||||||
"in")
|
line ("echo () { printf \"%s\\n\" \"$*\" ; }")
|
||||||
line ("--help|h) usage ;;") line (
|
line ("cmdexists () { type \"$1\" >/dev/null 2>&1 ; }")
|
||||||
"CFLAGS=*) CFLAGS=${arg#*=} ;;") line ("LDFLAGS=*) "
|
line ("trycc () { test -z \"$CC\" && cmdexists \"$1\" && CC=$1 ; }")
|
||||||
"LDFLAGS=${arg#"
|
line ()
|
||||||
"*=} ;;")
|
line ("prefix=/usr/bin/")
|
||||||
line ("esac") line ("done") line () line (
|
line ("CFLAGS=\"-Wall -Wextra -O2\"")
|
||||||
"printf \"checking for C "
|
line ("LDFLAGS=")
|
||||||
"compiler... \"") line ("trycc gcc")
|
line ("CC=")
|
||||||
line ("trycc cc") line ("trycc clang") line (
|
line ()
|
||||||
"printf \"%%s\\n\" \"$CC\"") line ()
|
line ("for arg ; do")
|
||||||
line ("printf \"checking weather C compiler "
|
line ("case \"$arg\" in")
|
||||||
"works... \"") line ("status=\"fail\"")
|
line ("--help|h) usage ;;")
|
||||||
line ("tmpc=\"$(mktemp -d)/test.c\"")
|
line ("CFLAGS=*) CFLAGS=${arg#*=} ;;")
|
||||||
line (
|
line ("LDFLAGS=*) LDFLAGS=${arg#*=} ;;")
|
||||||
"echo \"typedef int x;\" > "
|
line ("esac")
|
||||||
"\"$tmpc\"") line ("if "
|
line ("done")
|
||||||
"output=$($CC "
|
line ()
|
||||||
"$CFLAGS -c -o "
|
line ("printf \"checking for C compiler... \"")
|
||||||
"/dev/null "
|
line ("trycc gcc")
|
||||||
"\"$tmpc\" "
|
line ("trycc cc")
|
||||||
"2>&1) "
|
line ("trycc clang")
|
||||||
"; then")
|
line ("printf \"%s\\n\" \"$CC\"")
|
||||||
line ("printf \"yes\\n\"") line (
|
line ()
|
||||||
"else") line ("printf \"no; "
|
line ("printf \"checking weather C compiler works... \"")
|
||||||
"%%s\\n\" "
|
line ("status=\"fail\"")
|
||||||
"\"$output\"")
|
line ("tmpc=\"$(mktemp -d)/test.c\"")
|
||||||
line ("exit 1") line (
|
line ("echo \"typedef int x;\" > \"$tmpc\"")
|
||||||
"fi") line () line ("print"
|
line ("if output=$($CC $CFLAGS -c -o /dev/null \"$tmpc\" 2>&1) ; then")
|
||||||
"f "
|
line ("printf \"yes\\n\"")
|
||||||
"\"cre"
|
line ("else")
|
||||||
"ating"
|
line ("printf \"no; %s\\n\" \"$output\"")
|
||||||
" "
|
line ("exit 1")
|
||||||
"confi"
|
line ("fi")
|
||||||
"g."
|
line ()
|
||||||
"mak.."
|
line ("printf \"creating config.mak... \"")
|
||||||
". \"")
|
line ("printf \"PREFIX=%s\\n\" \"$prefix\" > config.mak")
|
||||||
line ("printf "
|
line ("printf \"CFLAGS=%s\\n\" \"$CFLAGS\" >> config.mak")
|
||||||
"\"PREFIX=%%s\\n\" "
|
line ("printf \"LDFLAGS=%s\\n\" \"$LDFLAGS\" >> config.mak")
|
||||||
"\"$prefix\" > "
|
line ("printf \"CC=%s\\n\" \"$CC\" >> config.mak")
|
||||||
"config.mak")
|
line ("printf \"done\\n\"");
|
||||||
line ("printf "
|
|
||||||
"\"CFLAGS=%%"
|
|
||||||
"s\\n\" "
|
|
||||||
"\"$CFLAGS\" >> "
|
|
||||||
"config.mak")
|
|
||||||
line (
|
|
||||||
"printf "
|
|
||||||
"\"LDFLAGS=%%"
|
|
||||||
"s\\n\" "
|
|
||||||
"\"$LDFLAGS\" "
|
|
||||||
">> "
|
|
||||||
"config.mak")
|
|
||||||
line (
|
|
||||||
"printf "
|
|
||||||
"\"CC=%%"
|
|
||||||
"s\\n\" "
|
|
||||||
"\"$CC\" "
|
|
||||||
">> "
|
|
||||||
"config."
|
|
||||||
"mak")
|
|
||||||
line (
|
|
||||||
"print"
|
|
||||||
"f "
|
|
||||||
"\"don"
|
|
||||||
"e\\n"
|
|
||||||
"\"");
|
|
||||||
|
|
||||||
/* Makefile template */
|
/* Makefile template */
|
||||||
char *makefile_template = line ("prefix = /usr/bin") line () line (
|
char *makefile_template =
|
||||||
"%s_SRCS := $(shell find . -name '%s/*.c')") line ("%s_OBJS := $(patsubst "
|
line ("prefix = /usr/bin")
|
||||||
"./%.c,c-out/obj/"
|
line ()
|
||||||
"%.o,$(%s_SRCS))")
|
line ("%s_SRCS := $(shell find . -name '%s/*.c')")
|
||||||
line () line ("%s := c-out/bin/%s") line () line ("-include config.mak")
|
line ("%s_OBJS := $(patsubst ./%.c,c-out/obj/%%.o,$(%s_SRCS))")
|
||||||
line () line ("ifeq ($(wildcard config.mak),)") line ("all:") line (
|
line ()
|
||||||
"\t@echo \"File config.mak not found, run configure\"")
|
line ("%s := c-out/bin/%s")
|
||||||
line ("\t@exit 1") line ("else") line () line ("all: build $(%s)")
|
line ()
|
||||||
line () line ("build:") line ("\tmkdir -p c-out/bin") line (
|
line ("-include config.mak")
|
||||||
"\tmkdir -p c-out/obj") line () line ("c-out/obj/%.o: %.c")
|
line ()
|
||||||
line ("\t$(CC) $(CFLAGS) -c $< -o $@") line ()
|
line ("ifeq ($(wildcard config.mak),)")
|
||||||
line ("$(%s): $(%s_OBJS)") line (
|
line ("all:")
|
||||||
"\t$(CC) $(CFLAGS) -DCOMMIT=$(shell git rev-list "
|
line ("\t@echo \"File config.mak not found, run configure\"")
|
||||||
"--count --all 2>/dev/null || echo 0) $^ -o $@")
|
line ("\t@exit 1")
|
||||||
line () line ("endif") line () line ("install:")
|
line ("else")
|
||||||
line ("\t@echo \"NOT IMPL\"") line (
|
line ()
|
||||||
"\texit 1") line () line ("uninstall:")
|
line ("all: build $(%s)")
|
||||||
line ("\t@echo \"NOT IMPL\"") line (
|
line ()
|
||||||
"\texit 1") line () line ("clean:")
|
line ("build:")
|
||||||
line ("\trm -rf c-out") line ()
|
line ("\tmkdir -p c-out/bin")
|
||||||
line ("dist-clean: clean") line (
|
line ("\tmkdir -p c-out/obj")
|
||||||
"\trm -f config.mak") line ()
|
line ()
|
||||||
line (
|
line ("c-out/obj/%%.o: %%.c")
|
||||||
".PHONY: all clean "
|
line ("\t$(CC) $(CFLAGS) -c $< -o $@")
|
||||||
"dist-clean install "
|
line ()
|
||||||
"uninstall build format");
|
line ("$(%s): $(%s_OBJS)")
|
||||||
|
line ("\t$(CC) $(CFLAGS) -DCOMMIT=$(shell git rev-list --count --all 2>/dev/null || echo 0) $^ -o $@")
|
||||||
|
line ()
|
||||||
|
line ("endif")
|
||||||
|
line ()
|
||||||
|
line ("install:")
|
||||||
|
line ("\t@echo \"NOT IMPL\"")
|
||||||
|
line ("\texit 1")
|
||||||
|
line ()
|
||||||
|
line ("uninstall:")
|
||||||
|
line ("\t@echo \"NOT IMPL\"")
|
||||||
|
line ("\texit 1")
|
||||||
|
line ()
|
||||||
|
line ("clean:")
|
||||||
|
line ("\trm -rf c-out")
|
||||||
|
line ()
|
||||||
|
line ("dist-clean: clean")
|
||||||
|
line ("\trm -f config.mak")
|
||||||
|
line ()
|
||||||
|
line (".PHONY: all clean dist-clean install uninstall build format");
|
||||||
|
|
||||||
/* .clang-format template */
|
/* .clang-format template */
|
||||||
char *clang_format_template = line ("BasedOnStyle: GNU");
|
char *clang_format_template =
|
||||||
|
line ("BasedOnStyle: GNU");
|
||||||
|
|
||||||
/* BSD 3-Clause License template */
|
/* BSD 3-Clause License template */
|
||||||
char *bsd3_license_template = line ("BSD 3-Clause License") line () line (
|
char *bsd3_license_template =
|
||||||
"Copyright (c) %d, %s") line () line ("Redistribution and use in source "
|
line ("BSD 3-Clause License")
|
||||||
"and binary forms, with or without")
|
line ()
|
||||||
line ("modification, are permitted provided that the following conditions "
|
line ("Copyright (c) %d, %s")
|
||||||
"are met:") line () line ("1. Redistributions of source code must "
|
line ()
|
||||||
"retain the above copyright "
|
line ("Redistribution and use in source and binary forms, with or without")
|
||||||
"notice, this")
|
line ("modification, are permitted provided that the following conditions are met:")
|
||||||
line (
|
line ()
|
||||||
" list of conditions and the following "
|
line ("1. Redistributions of source code must retain the above copyright notice, this")
|
||||||
"disclaimer.") line () line ("2. Redistributions in binary form "
|
line (" list of conditions and the following disclaimer.")
|
||||||
"must reproduce the above "
|
line ()
|
||||||
"copyright notice,") line (" this")
|
line ("2. Redistributions in binary form must reproduce the above copyright notice,")
|
||||||
line ("list of conditions and the following disclaimer in the "
|
line (" this list of conditions and the following disclaimer in the documentation")
|
||||||
"documentation") line (" and/or other materials provided "
|
line (" and/or other materials provided with the distribution.")
|
||||||
"with "
|
line ()
|
||||||
"the distribution.") line ()
|
line ("3. Neither the name of the copyright holder nor the names of its")
|
||||||
line ("3. Neither the name of the copyright holder nor the "
|
line (" contributors may be used to endorse or promote products derived from")
|
||||||
"names "
|
line (" this software without specific prior written permission.")
|
||||||
"of its") line (" contributors may be used to endorse "
|
line ()
|
||||||
"or "
|
line ("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"")
|
||||||
"promote products derived from")
|
line ("AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE")
|
||||||
line (
|
line ("IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")
|
||||||
" this software without specific prior written "
|
line ("DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE")
|
||||||
"permission.") line () line ("THIS SOFTWARE IS "
|
line ("FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL")
|
||||||
"PROVIDED BY THE "
|
line ("DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR")
|
||||||
"COPYRIGHT "
|
line ("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER")
|
||||||
"HOLDERS AND "
|
line ("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,")
|
||||||
"CONTRIBUTORS \"AS IS\"")
|
line ("OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE")
|
||||||
line ("AND ANY EXPRESS OR IMPLIED WARRANTIES, "
|
line ("OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.");
|
||||||
"INCLUDING, "
|
|
||||||
"BUT NOT LIMITED TO, THE") line ("IMPLIED "
|
|
||||||
"WARRANTIES OF "
|
|
||||||
"MERCHANTABILIT"
|
|
||||||
"Y AND FITNESS "
|
|
||||||
"FOR A "
|
|
||||||
"PARTICULAR "
|
|
||||||
"PURPOSE ARE")
|
|
||||||
line (
|
|
||||||
"DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT "
|
|
||||||
"HOLDER OR CONTRIBUTORS BE LIABLE")
|
|
||||||
line ("FOR ANY DIRECT, INDIRECT, INCIDENTAL, "
|
|
||||||
"SPECIAL, "
|
|
||||||
"EXEMPLARY, OR CONSEQUENTIAL")
|
|
||||||
line ("DAMAGES (INCLUDING, BUT NOT "
|
|
||||||
"LIMITED TO, "
|
|
||||||
"PROCUREMENT OF SUBSTITUTE GOODS OR")
|
|
||||||
line ("SERVICES; LOSS OF USE, DATA, "
|
|
||||||
"OR PROFITS; OR "
|
|
||||||
"BUSINESS INTERRUPTION) HOWEVER")
|
|
||||||
line ("CAUSED AND ON ANY THEORY "
|
|
||||||
"OF LIABILITY, "
|
|
||||||
"WHETHER IN CONTRACT, "
|
|
||||||
"STRICT LIABILITY,")
|
|
||||||
line ("OR TORT (INCLUDING "
|
|
||||||
"NEGLIGENCE OR "
|
|
||||||
"OTHERWISE) ARISING IN "
|
|
||||||
"ANY WAY OUT "
|
|
||||||
"OF THE USE")
|
|
||||||
line ("OF THIS SOFTWARE, "
|
|
||||||
"EVEN IF ADVISED OF "
|
|
||||||
"THE POSSIBILITY OF "
|
|
||||||
"SUCH DAMAGE.");
|
|
||||||
/* MIT License template */
|
/* MIT License template */
|
||||||
char *mit_license_template =
|
char *mit_license_template =
|
||||||
line("THIS IS THE MIT LICENSE");
|
line ("THIS IS THE MIT LICENSE");
|
||||||
|
|
||||||
/* GPLv3 License template */
|
/* GPLv3 License template */
|
||||||
char *gplv3_license_template =
|
char *gplv3_license_template =
|
||||||
line("THIS IS THE GPLv3 LICENSE");
|
line ("THIS IS THE GPLv3 LICENSE");
|
||||||
|
|
||||||
/* config.h template */
|
/* config.h template */
|
||||||
char *config_h_template = line ("#ifndef CONFIG_H") line ("#define CONFIG_H")
|
char *config_h_template =
|
||||||
line () line ("/* Program information */") line ("#define PROGRAM \"%s\"")
|
line ("#ifndef CONFIG_H")
|
||||||
line ("#define LICENSE_line \"%s\"") line ("#define AUTHORS \"%s\"")
|
line ("#define CONFIG_H")
|
||||||
line ("#define VERSION \"pre-alpha\"") line ("#define YEAR 2025")
|
line ()
|
||||||
line () line ("#define HELP_REQUESTED 2")
|
line ("/* Program information */")
|
||||||
line ("#define ERROR_MEMORY_ALLOCATION 3")
|
line ("#define PROGRAM \"%s\"")
|
||||||
line ("#define ERROR_DIRECTORY_CREATION 4") line ()
|
line ("#define LICENSE_line \"%s\"")
|
||||||
line ("#endif");
|
line ("#define AUTHORS \"%s\"")
|
||||||
|
line ("#define VERSION \"pre-alpha\"")
|
||||||
|
line ("#define YEAR 2025")
|
||||||
|
line ()
|
||||||
|
line ("#define HELP_REQUESTED 2")
|
||||||
|
line ("#define ERROR_MEMORY_ALLOCATION 3")
|
||||||
|
line ("#define ERROR_DIRECTORY_CREATION 4")
|
||||||
|
line ()
|
||||||
|
line ("#endif");
|
||||||
|
|
||||||
/* main.c (non-GNU) template */
|
/* main.c (non-GNU) template */
|
||||||
char *main_c_template = line ("#include <stdio.h>") line ()
|
char *main_c_template =
|
||||||
line ("int main(void) {") line (" printf(\"%s: Hello %s!\\n\");")
|
line ("#include <stdio.h>")
|
||||||
line (" return 0;") line ("}");
|
line ()
|
||||||
|
line ("int main(void) {")
|
||||||
|
line (" printf(\"%s: Hello %s!\\n\");")
|
||||||
|
line (" return 0;")
|
||||||
|
line ("}");
|
||||||
|
|
||||||
/* main.c (GNU) template */
|
/* main.c (GNU) template */
|
||||||
char *main_c_gnu_template = line ("#include <stdio.h>")
|
char *main_c_gnu_template =
|
||||||
line ("#include \"standard.h\"") line () line ("void usage(int status) {")
|
line ("#include <stdio.h>")
|
||||||
line (" fprintf(stderr, \"Usage: %s [OPTION...]\\n\");")
|
line ("#include \"standard.h\"")
|
||||||
line (" fprintf(stderr, \" --help\\tdisplay the help text and "
|
line ()
|
||||||
"exit\\n\");")
|
line ("void usage(int status) {")
|
||||||
line (" fprintf(stderr, \" --version\\toutput version "
|
line (" fprintf(stderr, \"Usage: %s [OPTION...]\\n\");")
|
||||||
"information and exit\\n\");") line ("}") line ()
|
line (" fprintf(stderr, \" --help\\tdisplay the help text and exit\\n\");")
|
||||||
line ("int main(int argc, char **argv) {")
|
line (" fprintf(stderr, \" --version\\toutput version information and exit\\n\");")
|
||||||
line (" parse_standard_options(usage, argc, argv);")
|
line ("}")
|
||||||
line (" printf(\"%s: Hello %s!\\n\");")
|
line ()
|
||||||
line (" return 0;") line ("}");
|
line ("int main(int argc, char **argv) {")
|
||||||
|
line (" parse_standard_options(usage, argc, argv);")
|
||||||
|
line (" printf(\"%s: Hello %s!\\n\");")
|
||||||
|
line (" return 0;")
|
||||||
|
line ("}");
|
||||||
|
|
||||||
/* standard.c template */
|
/* standard.c template */
|
||||||
char *standard_c_template = line ("#include \"standard.h\"") line (
|
char *standard_c_template =
|
||||||
"#include \"../config.h\"") line ("#include <stdio.h>")
|
line ("#include \"standard.h\"")
|
||||||
line ("#include <stdlib.h>") line ("#include <string.h>") line () line (
|
line ("#include \"../config.h\"")
|
||||||
"int") line ("parse_standard_options (void (*usage) (int), int argc, "
|
line ("#include <stdio.h>")
|
||||||
"char **argv)") line ("{")
|
line ("#include <stdlib.h>")
|
||||||
line (" for (int i = 1; i < argc; ++i)") line (" {") line (
|
line ("#include <string.h>")
|
||||||
" if (strcmp (argv[i], \"--help\") == 0)") line (" {")
|
line ()
|
||||||
line (" usage (0);") line (
|
line ("int")
|
||||||
" exit (EXIT_SUCCESS);") line (" }")
|
line ("parse_standard_options (void (*usage) (int), int argc, char **argv)")
|
||||||
line (" else if (strcmp (argv[i], \"--version\") == 0)")
|
line ("{")
|
||||||
line (" {") line (
|
line (" for (int i = 1; i < argc; ++i)")
|
||||||
" printf (\"%%s %%s %%d\\nCopyright (C) %%d "
|
line (" {")
|
||||||
"%%s.\\n%%s\\nThis is free software: you are free to "
|
line (" if (strcmp (argv[i], \"--help\") == 0)")
|
||||||
"change and redistribute it.\\nThere is NO WARRNTY, "
|
line (" {")
|
||||||
"to the extent permitted by law.\\n\", PROGRAM, "
|
line (" usage (0);")
|
||||||
"VERSION, COMMIT, YEAR, AUTHORS, LICENSE_line );")
|
line (" exit (EXIT_SUCCESS);")
|
||||||
line (" exit (EXIT_SUCCESS);")
|
line (" }")
|
||||||
line (" }") line (" }")
|
line (" else if (strcmp (argv[i], \"--version\") == 0)")
|
||||||
line (" return HELP_REQUESTED;") line ("}");
|
line (" {")
|
||||||
|
line (" 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 );")
|
||||||
|
line (" exit (EXIT_SUCCESS);")
|
||||||
|
line (" }")
|
||||||
|
line (" }")
|
||||||
|
line (" return HELP_REQUESTED;")
|
||||||
|
line ("}");
|
||||||
|
|
||||||
/* standard.h template */
|
/* standard.h template */
|
||||||
char *standard_h_template = line ("#ifndef STANDARD_H") line (
|
char *standard_h_template =
|
||||||
"#define STANDARD_H") line () line ("/**")
|
line ("#ifndef STANDARD_H")
|
||||||
line (" * Parse standard command line options (--help, --version)") line (
|
line ("#define STANDARD_H")
|
||||||
" * @param usage_func Function pointer to usage display function")
|
line ()
|
||||||
line (" * @param argc Argument count")
|
line ("/**")
|
||||||
line (" * @param argv Argument vector")
|
line (" * Parse standard command line options (--help, --version)")
|
||||||
line (" * @return 0 on success, 1 if help/version requested, "
|
line (" * @param usage_func Function pointer to usage display function")
|
||||||
"errno on error") line (" */")
|
line (" * @param argc Argument count")
|
||||||
line ("int parse_standard_options(void (*usage_func)(), "
|
line (" * @param argv Argument vector")
|
||||||
"int argc, char **argv);") line () line ("#endif");
|
line (" * @return 0 on success, 1 if help/version requested, errno on error")
|
||||||
|
line (" */")
|
||||||
|
line ("int parse_standard_options(void (*usage_func)(), int argc, char **argv);")
|
||||||
|
line ()
|
||||||
|
line ("#endif");
|
||||||
|
|
||||||
/* WHATNEXT.md template */
|
/* WHATNEXT.md template */
|
||||||
char *what_next_template = line ("# What next?") line ("") line ("## Steps")
|
char *what_next_template =
|
||||||
line (" - Write a description in the README")
|
line ("# What next?")
|
||||||
line (" - Write the usage function ( write to stderr )")
|
line ("")
|
||||||
line (" - Start writing your program");
|
line ("## Steps")
|
||||||
|
line (" - Write a description in the README")
|
||||||
|
line (" - Write the usage function ( write to stderr )")
|
||||||
|
line (" - Start writing your program");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// clang-format on
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "format.h"
|
#include "format.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>
|
||||||
@@ -15,8 +16,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
#define DEFAULT_USER_NAME "unknown"
|
#define DEFAULT_USER_NAME "unknown"
|
||||||
#define DEFAULT_PROJECT_NAME "Project"
|
#define DEFAULT_PROJECT_NAME "Project"
|
||||||
#define DEFAULT_LICENSE BSD3
|
#define DEFAULT_LICENSE BSD3
|
||||||
@@ -273,7 +272,6 @@ setup_git (format_t fmt)
|
|||||||
int
|
int
|
||||||
create_makefile (format_t fmt)
|
create_makefile (format_t fmt)
|
||||||
{
|
{
|
||||||
goto debug_skip;
|
|
||||||
char *makefile_name = strdup (fmt.project);
|
char *makefile_name = strdup (fmt.project);
|
||||||
if (!makefile_name)
|
if (!makefile_name)
|
||||||
{
|
{
|
||||||
@@ -290,10 +288,9 @@ create_makefile (format_t fmt)
|
|||||||
create_file_with_content ("Makefile", makefile_template, makefile_name,
|
create_file_with_content ("Makefile", makefile_template, makefile_name,
|
||||||
makefile_name, makefile_name, makefile_name,
|
makefile_name, makefile_name, makefile_name,
|
||||||
makefile_name, makefile_name, fmt.project,
|
makefile_name, makefile_name, fmt.project,
|
||||||
makefile_name);
|
makefile_name, makefile_name);
|
||||||
|
|
||||||
free (makefile_name);
|
free (makefile_name);
|
||||||
debug_skip:
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user