add install var
This commit is contained in:
parent
caf6b2f67d
commit
2a3c528022
48
README.md
48
README.md
|
@ -23,6 +23,14 @@ sudo ninja install -C build
|
|||
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
|
||||
|
||||
#### 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
|
||||
```
|
||||
using GLib;
|
||||
|
@ -45,8 +76,7 @@ using Pluie;
|
|||
|
||||
int main (string[] args)
|
||||
{
|
||||
OutputFormatter of;
|
||||
Echo.init (true /* enable tracing */, "resources/echo.ini", out of);
|
||||
var of = Echo.init (true /* enable tracing */, "resources/echo.ini" /* optional config file */);
|
||||
Dbg.in (Log.METHOD);
|
||||
|
||||
of.echo (
|
||||
|
@ -56,25 +86,27 @@ int main (string[] args)
|
|||
true,
|
||||
// indent all line
|
||||
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
|
||||
);
|
||||
...
|
||||
|
||||
Dbg.out (Log.METHOD);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
#### more samples
|
||||
|
||||
![Sample 1 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code1.png)
|
||||
![Sample 1 output](https://www.meta-tech.academy/img/libpluie-echo_sample1.png)
|
||||
![Sample 2 code](https://www.meta-tech.academy/img/libpluie-echo_sample_code2.png)
|
||||
![Sample 2 output](https://www.meta-tech.academy/img/libpluie-echo_sample2.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?tmp=1)
|
||||
![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?tmp=1)
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
configuration file is installed on {prefix}/share/pluie/echo.ini
|
||||
configuration file is installed by default on {prefix}/share/pluie/echo.ini
|
||||
|
||||
```
|
||||
[Term]
|
||||
|
|
9
install.vala.in
Normal file
9
install.vala.in
Normal 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@";
|
||||
}
|
||||
}
|
|
@ -7,9 +7,7 @@ errordomain MyError {
|
|||
|
||||
int main (string[] args)
|
||||
{
|
||||
OutputFormatter of;
|
||||
Echo.init (true, "resources/echo.ini", out of);
|
||||
|
||||
var of = Echo.init (true, "resources/echo.ini");
|
||||
Dbg.in (Log.METHOD, null, Log.LINE, Log.FILE);
|
||||
|
||||
of.title ("MyApp", "0.2.2", "a-sansara");
|
||||
|
|
11
meson.build
11
meson.build
|
@ -14,13 +14,20 @@ conf.set('VERSION' , version)
|
|||
conf.set('INSTALL_PATH', bindir)
|
||||
conf.set('DATA_PATH' , datadir)
|
||||
|
||||
configure_file(
|
||||
input: 'install.vala.in',
|
||||
output: 'install.vala',
|
||||
configuration: conf
|
||||
)
|
||||
|
||||
sources = [
|
||||
'src/Pluie.Color.vala',
|
||||
'src/Pluie.ColorConf.vala',
|
||||
'src/Pluie.Dbg.vala',
|
||||
'src/Pluie.global.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)
|
||||
|
@ -35,7 +42,7 @@ libpluie_echo = library('pluie-echo-' + version, sources,
|
|||
pkgconfig = import('pkgconfig')
|
||||
pkgconfig.generate(libraries: libpluie_echo,
|
||||
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,
|
||||
name: 'libpluie-echo',
|
||||
filebase: 'pluie-echo-' + version,
|
||||
|
|
|
@ -12,9 +12,9 @@ option = 37,1
|
|||
option_sep = 158
|
||||
arg = 97,1
|
||||
arg_sep = 147,1
|
||||
title = 15,1,24
|
||||
title = 15,1,97
|
||||
title_item = 220,1
|
||||
title_sep = 24,1
|
||||
title_sep = 97,1
|
||||
section = 37
|
||||
sep = 59
|
||||
item = 215,1
|
||||
|
|
|
@ -35,11 +35,14 @@ namespace Pluie
|
|||
|
||||
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);
|
||||
of = new OutputFormatter (conf);
|
||||
Dbg.init (of, debug);
|
||||
var conf = new ColorConf (path ?? Path.build_filename (DATA_PATH, "echo.ini"));
|
||||
Echo.of = new OutputFormatter (conf);
|
||||
Dbg.init (Echo.of, debug);
|
||||
return Echo.of;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user