2017-11-04 02:14:21 +00:00
|
|
|
# libpluie-echo
|
|
|
|
|
|
|
|
small vala shared library managing tracing, display formatting and ansi-extended colors on stdout & stderror.
|
|
|
|
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
valac meson ninja glib gobject
|
|
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
git clone the project then cd to project and do :
|
|
|
|
|
|
|
|
```
|
|
|
|
meson --prefix=/usr ./ build
|
|
|
|
sudo ninja install -C build
|
|
|
|
```
|
|
|
|
|
|
|
|
## Compilation
|
|
|
|
|
|
|
|
```
|
2017-11-17 22:01:08 +00:00
|
|
|
valac --pkg pluie-echo-0.2 main.vala -o echo
|
2017-11-04 02:14:21 +00:00
|
|
|
```
|
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
## Api / Documentation
|
|
|
|
|
|
|
|
https://pluie.org/pluie-echo-0.2/index.htm
|
|
|
|
|
2017-11-07 01:02:32 +00:00
|
|
|
## Docker
|
|
|
|
|
|
|
|
a demo image is available on docker hub. you can run a container with :
|
|
|
|
|
|
|
|
```
|
|
|
|
docker run --rm -it pluie/libecho
|
|
|
|
```
|
|
|
|
|
2017-11-04 02:14:21 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
#### playing with colors
|
|
|
|
```
|
|
|
|
using Pluie;
|
|
|
|
|
|
|
|
int main (string[] args)
|
|
|
|
{
|
2017-11-17 22:01:08 +00:00
|
|
|
var c1 = new Color( 37, false);
|
2017-11-04 02:14:21 +00:00
|
|
|
var c2 = new Color(204, true);
|
2017-11-17 22:01:08 +00:00
|
|
|
var c3 = new Color( 15, true, 24);
|
|
|
|
stdout.printf ("[%s][%s]%s\n", c1.s ("oki"), c2.s ("it's"), c3.s (" cool "));
|
2017-11-04 02:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-11-07 01:02:32 +00:00
|
|
|
#### playing with ColorConf
|
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
see samples/pluie-outputFormatter.vala
|
2017-11-07 01:02:32 +00:00
|
|
|
```
|
2017-11-17 22:01:08 +00:00
|
|
|
cd samples
|
|
|
|
valac --pkg pluie-echo-0.2 pluie-outputFormatter.vala
|
2017-11-07 01:02:32 +00:00
|
|
|
```
|
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
run ./pluie-outputFormatter
|
2017-11-07 01:02:32 +00:00
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
![ColorConf 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_colorconf2.png)
|
2017-11-07 01:02:32 +00:00
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
then, change in samples/echo.ini :
|
2017-11-07 01:02:32 +00:00
|
|
|
```
|
2017-11-17 22:01:08 +00:00
|
|
|
title = 15,1,24
|
2017-11-07 01:02:32 +00:00
|
|
|
title_item = 220,1
|
2017-11-17 22:01:08 +00:00
|
|
|
title_sep = 24,1
|
2017-11-07 01:02:32 +00:00
|
|
|
```
|
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
run ./pluie-outputFormatter again :
|
2017-11-07 01:02:32 +00:00
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
![ColorConf 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_colorconf1.png)
|
2017-11-07 01:02:32 +00:00
|
|
|
|
|
|
|
|
2017-11-04 02:14:21 +00:00
|
|
|
#### init OutputFormatter
|
|
|
|
```
|
|
|
|
using GLib;
|
|
|
|
using Pluie;
|
|
|
|
|
|
|
|
int main (string[] args)
|
|
|
|
{
|
2017-11-17 22:01:08 +00:00
|
|
|
Echo.init (true /* enable tracing */, "resources/echo.ini" /* optional config file */);
|
2017-11-04 02:14:21 +00:00
|
|
|
Dbg.in (Log.METHOD);
|
|
|
|
|
|
|
|
of.echo (
|
|
|
|
// multiline string
|
|
|
|
"\nsample echo\non multiple\nline",
|
|
|
|
// newline
|
|
|
|
true,
|
|
|
|
// indent all line
|
|
|
|
true,
|
2017-11-07 01:02:32 +00:00
|
|
|
// set color with Pluie.ECHO enum (listing all defined styles in echo.ini)
|
2017-11-04 02:14:21 +00:00
|
|
|
ECHO.ACTION
|
|
|
|
);
|
|
|
|
...
|
2017-11-07 01:02:32 +00:00
|
|
|
|
|
|
|
Dbg.out (Log.METHOD);
|
2017-11-04 02:14:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### more samples
|
|
|
|
|
2017-11-17 22:01:08 +00:00
|
|
|
see samples/
|
|
|
|
![Sample 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code1.png?tmp=2)
|
2017-11-07 01:02:32 +00:00
|
|
|
![Sample 1 output](https://www.meta-tech.academy/img/libpluie-echo_sample1.png?tmp=1)
|
2017-11-17 22:01:08 +00:00
|
|
|
![Sample 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code2.png?tmp=2)
|
2017-11-07 01:02:32 +00:00
|
|
|
![Sample 2 output](https://www.meta-tech.academy/img/libpluie-echo_sample2.png?tmp=1)
|
2017-11-04 02:14:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2017-11-07 01:02:32 +00:00
|
|
|
configuration file is installed by default on {prefix}/share/pluie/echo.ini
|
2017-11-04 02:14:21 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
[Term]
|
|
|
|
term_width = 105
|
|
|
|
indent = 4
|
|
|
|
key_maxlen = 17
|
|
|
|
|
|
|
|
[Colors]
|
2017-11-17 22:01:08 +00:00
|
|
|
# key are fixed. overwrite only values
|
2017-11-04 02:14:21 +00:00
|
|
|
# fg ansi extended color code (0..255), bold (0|1), bg ansi extended color code (0..255)
|
|
|
|
default =
|
|
|
|
comment = 103,1
|
2017-11-17 22:01:08 +00:00
|
|
|
command = 74,1
|
|
|
|
param = 117,1
|
|
|
|
bin = 15,1
|
2017-11-04 02:14:21 +00:00
|
|
|
option = 37,1
|
|
|
|
option_sep = 158
|
|
|
|
arg = 97,1
|
|
|
|
arg_sep = 147,1
|
|
|
|
title = 15,1,24
|
|
|
|
title_item = 220,1
|
|
|
|
title_sep = 24,1
|
|
|
|
section = 37
|
|
|
|
sep = 59
|
|
|
|
item = 215,1
|
|
|
|
action = 97,1
|
|
|
|
done = 15,1,36
|
|
|
|
fail = 15,1,196
|
|
|
|
key = 37,1
|
|
|
|
val = 215,1
|
|
|
|
date = 215,1
|
|
|
|
time = 210,1
|
|
|
|
microtime = 204,1
|
|
|
|
file = 95,1
|
|
|
|
num = 218,1
|
|
|
|
enter = 36,1
|
|
|
|
leave = 167,1
|
|
|
|
warn = 220,1,89
|
|
|
|
error = 15,1,196
|
|
|
|
```
|