format: GNU
This commit is contained in:
7
core/e.c
7
core/e.c
@@ -2,8 +2,11 @@
|
||||
#include "print.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
error_t unwrap(error_t err) {
|
||||
if (!err.null) {
|
||||
error_t
|
||||
unwrap (error_t err)
|
||||
{
|
||||
if (!err.null)
|
||||
{
|
||||
printfn ("error: %s", err.src);
|
||||
exit (err.status);
|
||||
}
|
||||
|
||||
14
core/file.c
14
core/file.c
@@ -7,7 +7,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
error_t touch(char *path, char *format, ...) {
|
||||
error_t
|
||||
touch (char *path, char *format, ...)
|
||||
{
|
||||
error_t err = { 0 };
|
||||
err.null = true; // success by default
|
||||
|
||||
@@ -15,7 +17,8 @@ error_t touch(char *path, char *format, ...) {
|
||||
va_start (args, format);
|
||||
|
||||
FILE *fp = fopen (path, "w");
|
||||
if (!fp) {
|
||||
if (!fp)
|
||||
{
|
||||
err.null = false;
|
||||
err.status = errno;
|
||||
err.src = strerror (errno);
|
||||
@@ -30,7 +33,9 @@ error_t touch(char *path, char *format, ...) {
|
||||
return err;
|
||||
}
|
||||
|
||||
error_t dir(char *format, ...) {
|
||||
error_t
|
||||
dir (char *format, ...)
|
||||
{
|
||||
error_t err = { 0 };
|
||||
err.null = true; // success by default
|
||||
|
||||
@@ -42,7 +47,8 @@ error_t dir(char *format, ...) {
|
||||
|
||||
va_end (args);
|
||||
|
||||
if (mkdir(path, 0777) < 0) {
|
||||
if (mkdir (path, 0777) < 0)
|
||||
{
|
||||
err.null = false;
|
||||
err.status = errno;
|
||||
err.src = strerror (errno);
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int printfn(char *format, ...) {
|
||||
int
|
||||
printfn (char *format, ...)
|
||||
{
|
||||
int len;
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
|
||||
31
yait/main.c
31
yait/main.c
@@ -1,33 +1,40 @@
|
||||
#include "../core/print.h"
|
||||
#include "../core/file.h"
|
||||
#include "../core/print.h"
|
||||
#include "format.h"
|
||||
|
||||
int create (format_t);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) {
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printfn ("error: not enough arguments.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
format_t conf;
|
||||
conf.name = argv[1];
|
||||
conf.nogit = false;
|
||||
|
||||
create (conf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int create(format_t fmt) {
|
||||
int
|
||||
create (format_t fmt)
|
||||
{
|
||||
take (fmt.name);
|
||||
|
||||
touch ("README",
|
||||
"%s ( concise description )\n\n"
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\n"
|
||||
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis\n"
|
||||
"nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n"
|
||||
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu\n"
|
||||
"fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n"
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
|
||||
"eiusmod tempor\n"
|
||||
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis\n"
|
||||
"nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo "
|
||||
"consequat.\n"
|
||||
"Duis aute irure dolor in reprehenderit in voluptate velit esse "
|
||||
"cillum dolore eu\n"
|
||||
"fugiat nulla pariatur. Excepteur sint occaecat cupidatat non "
|
||||
"proident, sunt in\n"
|
||||
"culpa qui officia deserunt mollit anim id est laborum.",
|
||||
fmt.name);
|
||||
touch ("hello", "world");
|
||||
|
||||
Reference in New Issue
Block a user