fix: better way to validate the config, add options to git clone
This commit is contained in:
43
src/log.c
43
src/log.c
@ -1,5 +1,8 @@
|
||||
#include "log.h"
|
||||
#include "env.h"
|
||||
#include "intl.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -88,6 +91,17 @@ void error(const char *msg, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void details(const char *msg, ...) {
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
||||
printf(" "COLOR_RESET);
|
||||
vprintf(msg, args);
|
||||
printf(COLOR_RESET "\n");
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void success(const char *msg, ...) {
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
@ -112,3 +126,32 @@ void debug(const char *msg, ...) {
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void input(const char *msg, ...) {
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
||||
printf(COLOR_BOLD COLOR_CYAN ">>> " COLOR_RESET COLOR_BOLD);
|
||||
vprintf(msg, args);
|
||||
printf(COLOR_RESET);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
bool yesno(const char *msg){
|
||||
char question[strlen(msg)+12], inp[2] = {'n','\0'}, c;
|
||||
sprintf(question, "%s [y/n]? ", msg);
|
||||
|
||||
while(true){
|
||||
input(question);
|
||||
scanf("%c", &c);
|
||||
inp[0] = c;
|
||||
|
||||
if(eq(inp, _("y")) || eq(inp, _("Y")))
|
||||
return true;
|
||||
else if(eq(inp, _("n")) || eq(inp, _("N")))
|
||||
return false;
|
||||
|
||||
error(_("Please answer with y/n"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user