diff --git a/.berel.yml b/.berel.yml index 21346b6..306b5ed 100644 --- a/.berel.yml +++ b/.berel.yml @@ -15,7 +15,7 @@ - sh : file : - build.sh - startline : 2 + startline : 2 # to embed shebang before header tpl sepline : motif : "# " repeat : 40 @@ -41,6 +41,7 @@ - .vala file : - install.vala.in + - main.vala startline : 1 sepline : motif : " *" diff --git a/build.sh b/build.sh index e69c3cb..cfd6c75 100755 --- a/build.sh +++ b/build.sh @@ -1,31 +1,31 @@ #!/bin/bash #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# +# # @software : berel -# @version : 0.21 -# @type : program -# @date : 2018 +# @version : 0.21 +# @type : program +# @date : 2018 # @license : GPLv3.0 # @author : a-Sansara <[dev]at[pluie]dot[org]> # @copyright : 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 . -# +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# meson --prefix=/usr/local ./ build diff --git a/install.vala.in b/install.vala.in index 23b2fd8..ce7f06f 100644 --- a/install.vala.in +++ b/install.vala.in @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ namespace Pluie diff --git a/main.vala b/main.vala index fbf50c1..f742fd9 100644 --- a/main.vala +++ b/main.vala @@ -1,3 +1,32 @@ +/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * @software : berel + * @version : 0.21 + * @type : program + * @date : 2018 + * @license : GPLv3.0 + * @author : a-Sansara <[dev]at[pluie]dot[org]> + * @copyright : 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 . + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ + using GLib; using Gee; using Pluie; diff --git a/meson.build b/meson.build index 43b4c23..a20290e 100644 --- a/meson.build +++ b/meson.build @@ -1,30 +1,30 @@ #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# +# # @software : berel -# @version : 0.21 -# @type : program -# @date : 2018 +# @version : 0.21 +# @type : program +# @date : 2018 # @license : GPLv3.0 # @author : a-Sansara <[dev]at[pluie]dot[org]> # @copyright : 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 . -# +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# project('berel', 'vala', 'c', version:'0.21') diff --git a/src/Pluie/Berel.App.vala b/src/Pluie/Berel.App.vala index d6b7194..99f4c3e 100644 --- a/src/Pluie/Berel.App.vala +++ b/src/Pluie/Berel.App.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ using GLib; @@ -93,13 +93,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 (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); @@ -115,16 +118,21 @@ public class Pluie.Berel.App 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); + this.write_file (p, data); + } } } + catch(GLib.FileError e) { + of.error (e.message); + } of.echo (" < directory %s".printf (path)); } diff --git a/src/Pluie/Berel.Comment.vala b/src/Pluie/Berel.Comment.vala index ee5d527..fc9fdbd 100644 --- a/src/Pluie/Berel.Comment.vala +++ b/src/Pluie/Berel.Comment.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ 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 (); } } diff --git a/src/Pluie/Berel.HeaderDef.vala b/src/Pluie/Berel.HeaderDef.vala index f06165c..25ed5dd 100644 --- a/src/Pluie/Berel.HeaderDef.vala +++ b/src/Pluie/Berel.HeaderDef.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ using GLib; diff --git a/src/Pluie/Berel.Key.vala b/src/Pluie/Berel.Key.vala index 71a5c69..23a75be 100644 --- a/src/Pluie/Berel.Key.vala +++ b/src/Pluie/Berel.Key.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ using GLib; diff --git a/src/Pluie/Berel.Meta.vala b/src/Pluie/Berel.Meta.vala index c98f131..82b6aaa 100644 --- a/src/Pluie/Berel.Meta.vala +++ b/src/Pluie/Berel.Meta.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ 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 (); - 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; } diff --git a/src/Pluie/Berel.Sepline.vala b/src/Pluie/Berel.Sepline.vala index e6be585..f3c97ab 100644 --- a/src/Pluie/Berel.Sepline.vala +++ b/src/Pluie/Berel.Sepline.vala @@ -1,30 +1,30 @@ /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * + * * @software : berel - * @version : 0.21 - * @type : program - * @date : 2018 + * @version : 0.21 + * @type : program + * @date : 2018 * @license : GPLv3.0 * @author : a-Sansara <[dev]at[pluie]dot[org]> * @copyright : 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 . - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/ using GLib;