Compare commits

..

3 Commits
0.21 ... master

Author SHA1 Message Date
a-Sansara
90af78dfdf using pluie-yaml-0.6 use Yaml.Loader.PACK_NESTED_ENTRIES option 2018-09-05 02:21:54 +02:00
a-Sansara
85c70bca5e update build 2018-08-28 23:59:35 +02:00
a-sansara
6499b5c9d0 apply chomp in header tpl + fix exec file perm fo sh headerdef 2018-08-28 15:05:54 +02:00
13 changed files with 240 additions and 176 deletions

View File

@ -4,7 +4,7 @@
!v!Pluie.Berel.Meta meta :
keys :
software : berel; <https://git.pluie.org/pluie/berel>
version : 0.21
version : 0.25
type : program
date : 2018
license : GPLv3.0; <http://www.gnu.org/licenses/>
@ -15,7 +15,7 @@
- sh :
file :
- build.sh
startline : 2
startline : 2 # to embed shebang before header tpl
sepline :
motif : "# "
repeat : 40
@ -26,7 +26,7 @@
- meson :
file :
- meson.build
startline : 1
- src/meson.build
sepline :
motif : "# "
repeat : 40
@ -39,9 +39,6 @@
- src
extension :
- .vala
file :
- install.vala.in
startline : 1
sepline :
motif : " *"
repeat : 40

View File

@ -1,31 +1,31 @@
#!/bin/bash
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.21
# @type : program
# @date : 2018
# @version : 0.25
# @type : program
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of berel.
#
#
# berel is free software (free as in speech) : 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.
#
#
# berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
meson --prefix=/usr/local ./ build

View File

@ -1,17 +0,0 @@
using GLib;
using Gee;
using Pluie;
int main (string[] args)
{
Echo.init(false);
var done = false;
var app = new Berel.App();
done = app!=null && app.done;
of.rs (done);
of.echo ();
return (int) done;
}

View File

@ -1,73 +1,61 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.21
# @type : program
# @date : 2018
# @version : 0.25
# @type : program
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of berel.
#
#
# berel is free software (free as in speech) : 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.
#
#
# berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
#
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
project('berel', 'vala', 'c', version:'0.21')
project('berel', ['vala', 'c'], version:'0.22')
cc = meson.get_compiler('c')
dep_glib = dependency('glib-2.0')
dep_gobject = dependency('gobject-2.0')
dep_gmodule = dependency('gmodule-2.0')
dep_gio = dependency('gio-2.0')
dep_gee = dependency('gee-0.8')
dep_echo = dependency('pluie-echo-0.2')
dep_yaml = dependency('pluie-yaml-0.5')
dep_m = cc.find_library('m', required : false)
# dep_yaml = cc.find_library('yaml', required : true)
version = meson.project_version()
bindir = join_paths(get_option('prefix'), get_option('bindir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie/berel')
libdir = join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
incdir = join_paths(get_option('prefix'), get_option('includedir'), 'pluie')
conf = configuration_data()
conf.set('VERSION' , version)
conf.set('INSTALL_PATH', bindir)
conf.set('DATA_PATH' , datadir)
conf = configuration_data()
conf.set('VERSION' , meson.project_version())
conf.set('INSTALL_PATH', join_paths(get_option('prefix'), get_option('bindir')))
conf.set('DATA_PATH' , join_paths(get_option('prefix'), get_option('datadir'), 'pluie/berel'))
configure_file(
input: 'install.vala.in',
input : 'src/install.vala',
output: 'install.vala',
configuration: conf
)
sources = [
'build/install.vala',
'src/Pluie/Berel.App.vala',
'src/Pluie/Berel.Comment.vala',
'src/Pluie/Berel.HeaderDef.vala',
'src/Pluie/Berel.Key.vala',
'src/Pluie/Berel.Meta.vala',
'src/Pluie/Berel.Sepline.vala',
'main.vala',
]
subdir('src')
executable('berel', sources, install : true, dependencies : [dep_glib, dep_gobject, dep_gmodule, dep_gio, dep_gee, dep_echo, dep_yaml, dep_m])
executable(
meson.project_name(),
src_files + [ 'build/install.vala' ],
install : true,
dependencies : [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gmodule-2.0'),
dependency('gio-2.0'),
dependency('gee-0.8'),
dependency('pluie-echo-0.2'),
dependency('pluie-yaml-0.5'),
meson.get_compiler('c').find_library('m', required : false)
]
)

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
@ -77,6 +77,7 @@ public class Pluie.Berel.App
{
bool done = false;
this.pwd = GLib.Environment.get_current_dir ();
Yaml.Loader.PACK_NESTED_ENTRIES = true;
var config = new Yaml.Config (Path.build_filename (path != null ? path : pwd, ".berel.yml"), false);
var root = config.root_node ();
root.name = Path.get_basename (pwd)+"/.berel.yml";
@ -93,13 +94,16 @@ public class Pluie.Berel.App
private void write_header (Berel.HeaderDef header)
{
of.action ("write headers from header def", header.yaml_name);
var hasHeader = false;
string? data = null;
string? path = null;
foreach (var name in header.file) {
path = Path.build_filename(this.pwd, name);
data = this.get_write_content(path, header);
this.write_file (path, data);
if (data.length > 0 && this.write_file (path, data)) {
if (header.yaml_name == "sh") {
FileUtils.chmod (path, 0775);
}
}
}
foreach (var name in header.dir) {
path = Path.build_filename(this.pwd, name);
@ -112,20 +116,23 @@ public class Pluie.Berel.App
*/
private void write_dir (string path, HeaderDef header)
{
of.echo (" > reading directory %s".printf (path));
string? dname = null;
string? data = null;
Dir dir = Dir.open (path, 0);
while ((dname = dir.read_name ()) != null) {
string? p = Path.build_filename (path, dname);
if (FileUtils.test (p, FileTest.IS_DIR))
this.write_dir (p, header);
else {
data = this.get_write_content(p, header, true);
this.write_file (p, data);
try {
Dir dir = Dir.open (path, 0);
while ((dname = dir.read_name ()) != null) {
string? p = Path.build_filename (path, dname);
if (FileUtils.test (p, FileTest.IS_DIR))
this.write_dir (p, header);
else {
data = this.get_write_content(p, header, true);
if (data.length > 00) this.write_file (p, data);
}
}
}
of.echo (" < directory %s".printf (path));
catch(GLib.FileError e) {
of.error (e.message);
}
}
/**

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
@ -68,6 +68,6 @@ public class Pluie.Berel.Comment : Yaml.Object
*/
public string get_line (string data, bool disabled = false)
{
return "%s%s".printf (disabled ? "" : this.begin, data);
return "%s%s".printf (disabled ? "" : this.begin, data).chomp ();
}
}

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
@ -34,7 +34,7 @@ public class Pluie.Berel.HeaderDef : Yaml.Object
{
public Gee.ArrayList<string> file { get; set; }
public Gee.ArrayList<string> dir { get; set; }
public int startline { get; set; }
public int startline { get; set; default = 1; }
public Berel.Sepline sepline { get; set; }
public Gee.ArrayList<string> extension { get; set; }
public Berel.Comment comment { get; set; }

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
@ -111,7 +111,7 @@ public class Pluie.Berel.Meta : Yaml.Object
sb.append("%s\n".printf (hd.comment.get_line(str, str==hd.sepline.to_string ())));
}
}
return "%s\n".printf (sb.str.substring (0, sb.str.length - 5 -(hd.sepline.motif[0] == ' ' ? 0 : 1) - hd.comment.end.length)+hd.comment.end);
return "%s%s\n".printf (sb.str.substring (0, sb.str.length - 3 - hd.comment.end.length), hd.comment.end);
}
/**
@ -119,20 +119,25 @@ public class Pluie.Berel.Meta : Yaml.Object
*/
public string tpl_replace_var (HeaderDef hd)
{
MatchInfo? mi = null;
Regex reg = new Regex ("\\^([^\\^]+)\\^");
string str = this.tpl;
this.varlist = new Gee.HashMap<string, string> ();
if (reg.match (str, 0, out mi)) {
this.define_var (mi.fetch (1), hd);
while (mi.next ()) {;
try {
MatchInfo? mi = null;
Regex reg = new Regex ("\\^([^\\^]+)\\^");
if (reg.match (str, 0, out mi)) {
this.define_var (mi.fetch (1), hd);
while (mi.next ()) {;
this.define_var (mi.fetch (1), hd);
}
}
foreach (var entry in this.varlist.entries) {
if (entry.value.length > 0) {
str = str.replace("^%s^".printf (entry.key), (entry.key == "sepline" ? "" : "")+entry.value);
}
}
}
foreach (var entry in this.varlist.entries) {
if (entry.value.length > 0) {
str = str.replace("^%s^".printf (entry.key), (entry.key == "sepline" ? "" : "")+entry.value);
}
catch (GLib.RegexError e) {
of.error (e.message);
}
return str;
}
@ -186,14 +191,14 @@ public class Pluie.Berel.Meta : Yaml.Object
}
int count = 0;
foreach (var bk in this.keys) {
sb.append (hd.comment.get_line("@%s%s : %s%s%s%s".printf (
sb.append (hd.comment.get_line("@%s%s : %s%s%s".printf (
bk.yaml_name,
string.nfill(lenk+2-bk.yaml_name.length, ' '),
bk.name,
string.nfill(len+2-bk.name.length, ' '),
bk.address != null ? " %s".printf (bk.address) : "",
count == this.keys.size -1 ? "" : "\n"
bk.address != null ? " %s".printf (bk.address) : ""
),count++ == 0));
sb.append ("\n");
}
return sb.str;
}

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* This file is part of berel.
*
*
* berel is free software (free as in speech) : 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.
*
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
namespace Pluie

46
src/main.vala Normal file
View File

@ -0,0 +1,46 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.25
* @type : program
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of berel.
*
* berel is free software (free as in speech) : 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.
*
* berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
using Gee;
using Pluie;
int main (string[] args)
{
Echo.init(false);
var done = false;
var app = new Berel.App();
done = app!=null && app.done;
of.rs (done);
of.echo ();
return (int) done;
}

38
src/meson.build Normal file
View File

@ -0,0 +1,38 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.25
# @type : program
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of berel.
#
# berel is free software (free as in speech) : 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.
#
# berel 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 berel. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
src_files = [
'src/Pluie/Berel.App.vala',
'src/Pluie/Berel.Comment.vala',
'src/Pluie/Berel.HeaderDef.vala',
'src/Pluie/Berel.Key.vala',
'src/Pluie/Berel.Meta.vala',
'src/Pluie/Berel.Sepline.vala',
'src/main.vala'
]