apply chomp in header tpl + fix exec file perm fo sh headerdef

This commit is contained in:
a-sansara 2018-08-28 15:05:54 +02:00
parent 3f4685db22
commit 6499b5c9d0
11 changed files with 160 additions and 117 deletions

View File

@ -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 : " *"

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.21
# @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,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.21
* @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

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @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;

View File

@ -1,30 +1,30 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# @software : berel <https://git.pluie.org/pluie/berel>
# @version : 0.21
# @type : program
# @date : 2018
# @version : 0.21
# @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')

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.21
* @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;
@ -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));
}

View File

@ -1,30 +1,30 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
*
* @software : berel <https://git.pluie.org/pluie/berel>
* @version : 0.21
* @type : program
* @date : 2018
* @version : 0.21
* @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.21
* @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.21
* @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.21
* @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.21
* @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;