add install var

This commit is contained in:
a-Sansara 2017-11-07 02:02:32 +01:00
parent caf6b2f67d
commit 2a3c528022
6 changed files with 69 additions and 20 deletions

View File

@ -23,6 +23,14 @@ sudo ninja install -C build
valac --pkg pluie-echo-0.1 main.vala -o echo valac --pkg pluie-echo-0.1 main.vala -o echo
``` ```
## Docker
a demo image is available on docker hub. you can run a container with :
```
docker run --rm -it pluie/libecho
```
## Usage ## Usage
#### playing with colors #### playing with colors
@ -38,6 +46,29 @@ int main (string[] args)
} }
``` ```
#### playing with ColorConf
compile main.vala
```
valac --pkg pluie-echo-0.1 main.vala -o echo
```
run ./echo
![ColorConf 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_colorconf1.png)
then, change in resources/echo.ini :
```
title = 15,1,97
title_item = 220,1
title_sep = 97,1
```
run echo again :
![ColorConf 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_colorconf2.png)
#### init OutputFormatter #### init OutputFormatter
``` ```
using GLib; using GLib;
@ -45,8 +76,7 @@ using Pluie;
int main (string[] args) int main (string[] args)
{ {
OutputFormatter of; var of = Echo.init (true /* enable tracing */, "resources/echo.ini" /* optional config file */);
Echo.init (true /* enable tracing */, "resources/echo.ini", out of);
Dbg.in (Log.METHOD); Dbg.in (Log.METHOD);
of.echo ( of.echo (
@ -56,25 +86,27 @@ int main (string[] args)
true, true,
// indent all line // indent all line
true, true,
// set color with Pluie.ECHO enum listing all defined styles // set color with Pluie.ECHO enum (listing all defined styles in echo.ini)
ECHO.ACTION ECHO.ACTION
); );
... ...
Dbg.out (Log.METHOD);
return 0; return 0;
} }
``` ```
#### more samples #### more samples
![Sample 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code1.png) ![Sample 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code1.png?tmp=1)
![Sample 1 output](https://www.meta-tech.academy/img/libpluie-echo_sample1.png) ![Sample 1 output](https://www.meta-tech.academy/img/libpluie-echo_sample1.png?tmp=1)
![Sample 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code2.png) ![Sample 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code2.png?tmp=1)
![Sample 2 output](https://www.meta-tech.academy/img/libpluie-echo_sample2.png) ![Sample 2 output](https://www.meta-tech.academy/img/libpluie-echo_sample2.png?tmp=1)
## Configuration ## Configuration
configuration file is installed on {prefix}/share/pluie/echo.ini configuration file is installed by default on {prefix}/share/pluie/echo.ini
``` ```
[Term] [Term]

9
install.vala.in Normal file
View File

@ -0,0 +1,9 @@
namespace Pluie
{
namespace Echo
{
protected const string INSTALL_PATH = "@INSTALL_PATH@";
protected const string DATA_PATH = "@DATA_PATH@";
protected const string VERSION = "@VERSION@";
}
}

View File

@ -7,9 +7,7 @@ errordomain MyError {
int main (string[] args) int main (string[] args)
{ {
OutputFormatter of; var of = Echo.init (true, "resources/echo.ini");
Echo.init (true, "resources/echo.ini", out of);
Dbg.in (Log.METHOD, null, Log.LINE, Log.FILE); Dbg.in (Log.METHOD, null, Log.LINE, Log.FILE);
of.title ("MyApp", "0.2.2", "a-sansara"); of.title ("MyApp", "0.2.2", "a-sansara");

View File

@ -14,13 +14,20 @@ conf.set('VERSION' , version)
conf.set('INSTALL_PATH', bindir) conf.set('INSTALL_PATH', bindir)
conf.set('DATA_PATH' , datadir) conf.set('DATA_PATH' , datadir)
configure_file(
input: 'install.vala.in',
output: 'install.vala',
configuration: conf
)
sources = [ sources = [
'src/Pluie.Color.vala', 'src/Pluie.Color.vala',
'src/Pluie.ColorConf.vala', 'src/Pluie.ColorConf.vala',
'src/Pluie.Dbg.vala', 'src/Pluie.Dbg.vala',
'src/Pluie.global.vala', 'src/Pluie.global.vala',
'src/Pluie.OutputFormatter.vala', 'src/Pluie.OutputFormatter.vala',
'src/Pluie.Sys.Cmd.vala' 'src/Pluie.Sys.Cmd.vala',
'build/install.vala'
] ]
install_data('resources/echo.ini', install_dir : datadir) install_data('resources/echo.ini', install_dir : datadir)
@ -35,7 +42,7 @@ libpluie_echo = library('pluie-echo-' + version, sources,
pkgconfig = import('pkgconfig') pkgconfig = import('pkgconfig')
pkgconfig.generate(libraries: libpluie_echo, pkgconfig.generate(libraries: libpluie_echo,
requires: 'glib-2.0 gobject-2.0', requires: 'glib-2.0 gobject-2.0',
variables: 'datarootdir=${prefix}/share\ndatadir=${datarootdir}/pluie', variables: 'datarootdir='+join_paths('${prefix}', get_option('datadir'))+'\ndatadir='+join_paths('${datarootdir}', 'pluie'),
version: version, version: version,
name: 'libpluie-echo', name: 'libpluie-echo',
filebase: 'pluie-echo-' + version, filebase: 'pluie-echo-' + version,

View File

@ -12,9 +12,9 @@ option = 37,1
option_sep = 158 option_sep = 158
arg = 97,1 arg = 97,1
arg_sep = 147,1 arg_sep = 147,1
title = 15,1,24 title = 15,1,97
title_item = 220,1 title_item = 220,1
title_sep = 24,1 title_sep = 97,1
section = 37 section = 37
sep = 59 sep = 59
item = 215,1 item = 215,1

View File

@ -35,11 +35,14 @@ namespace Pluie
namespace Echo namespace Echo
{ {
public void init (bool debug, string path, out OutputFormatter of) public static OutputFormatter of;
public OutputFormatter init (bool debug, string? path = null)
{ {
var conf = new ColorConf (path); var conf = new ColorConf (path ?? Path.build_filename (DATA_PATH, "echo.ini"));
of = new OutputFormatter (conf); Echo.of = new OutputFormatter (conf);
Dbg.init (of, debug); Dbg.init (Echo.of, debug);
return Echo.of;
} }
} }
} }