init
This commit is contained in:
commit
8334863111
14
Makefile
Normal file
14
Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
include config.mk
|
||||
|
||||
all:
|
||||
mkdir build
|
||||
cp src/evcli.h build/evcli.h
|
||||
$(CC) -c src/libevcli.c -o build/libevcli.o
|
||||
$(AR) -rc build/libevcli.a build/libevcli.o
|
||||
|
||||
install:
|
||||
install build/libevcli.a $(PREFIX)/lib
|
||||
install build/evcli.h $(PREFIX)/include
|
||||
|
||||
clean:
|
||||
rm -rf build
|
41
README
Normal file
41
README
Normal file
@ -0,0 +1,41 @@
|
||||
+ libevcli
|
||||
|
||||
A library unifying CLI output across Everest programs
|
||||
|
||||
+ Usage
|
||||
|
||||
#include <evcli.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
infolog("Info message");
|
||||
warnlog("Warning message");
|
||||
errlog("Error message");
|
||||
successlog("Success message");
|
||||
}
|
||||
|
||||
(user)$ gcc prog.c -levcli -o prog
|
||||
|
||||
No manpage is supplied, this library should be incredibly straightforward to use.
|
||||
|
||||
+ Caveats
|
||||
|
||||
None of the functions here can output variables. If you need to output variables:
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
printf(COL_BLUE "[i]" COL_RESET " %s\n", VAR);
|
||||
printf(COL_YELLOW "[!]" COL_RESET " %s\n", VAR);
|
||||
printf(COL_RED "[x]" COL_RESET " %s\n", VAR);
|
||||
printf(COL_GREEN "[%lc]" COL_RESET "%s\n", check, VAR);
|
||||
}
|
||||
|
||||
+ Installation
|
||||
|
||||
Run 'make' to build the static library. Run 'make install' to install the static library and header.
|
||||
|
||||
Run 'make clean' to remove all built files from the source tree.
|
26
src/evcli.h
Normal file
26
src/evcli.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* evcli.h - Function declarations for libevcli
|
||||
*
|
||||
* This file is part of libevcli.
|
||||
*
|
||||
* Libevcli is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libevcli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with libevcli. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EVCLI_H_
|
||||
#define EVCLI_H_
|
||||
|
||||
void infolog(char MSG[]);
|
||||
void warnlog(char MSG[]);
|
||||
void errlog(char MSG[]);
|
||||
void successlog(char MSG[]);
|
||||
|
||||
#endif
|
69
src/libevcli.c
Normal file
69
src/libevcli.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* libevcli.c - Library for Everest-styled command line output
|
||||
*
|
||||
* Libevcli is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libevcli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with libevcli. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <color.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <wchar.h>
|
||||
|
||||
const wchar_t check = 0x2713;
|
||||
|
||||
void
|
||||
infolog(char MSG[])
|
||||
{
|
||||
if (MSG == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(COL_BLUE "[i]" COL_RESET " %s\n", MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
warnlog(char MSG[])
|
||||
{
|
||||
if (MSG == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(COL_YELLOW "[!]" COL_RESET " %s\n", MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
errlog(char MSG[])
|
||||
{
|
||||
if (MSG == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, COL_RED "[x]" COL_RESET " %s\n", MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
successlog(char MSG[])
|
||||
{
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
if (MSG == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(COL_GREEN "[%lc]" COL_RESET " %s\n", check, MSG);
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue
Block a user