]> git.nbdom.net Git - nb.git/commitdiff
lib/php/out.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 29 Aug 2024 00:28:38 +0000 (02:28 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 29 Aug 2024 00:28:38 +0000 (02:28 +0200)
bin/dbq-vi
lib/php/out.php
lib/php/out/human.php

index 1666b0e32717bde8fb0284a7d4b978fa030b99cf..23b253f05d8e324dc4acaf17fd3a9b646264a612 100755 (executable)
@@ -5,7 +5,7 @@ main() {
        #exec echo $tmp
        dbq.php "$1/vi/$2.sh" > "$tmp" || return
 
-       perl -i -pe 's/(\w+=".*?") /$1\n/g; s/;\s*$// ' "$tmp"
+       perl -i -pe 's/(\w+=".*?") /$1\n/g; s/;\s*$/\n/ ' "$tmp"
 
        md5=$(md5sum "$tmp")
 
@@ -13,9 +13,9 @@ main() {
        [ -s "$tmp" ] || return 
        [ "$md5" == "$(md5sum "$tmp")" ] && return 
        bash -f "$tmp" || return
-       #exec echo $md5
+       #echo $md5 " == $(md5sum "$tmp")"
 
-       eval dbq.php $1/update/ $(cat "$tmp")
+       eval "dbq.php $1/update/ $(cat "$tmp")" | csv2human
 
 }
 
index cd89724da0c8d251d68713877d3b10275256eebc..cc3ae286450bd0083e9d8a48dff23e4a00c643cf 100644 (file)
@@ -581,17 +581,70 @@ Class Out extends Nb {
   }
 
   public static function out_human_end(&$o) {
+/*
+my $format = "│ ".join(" │ ",map {$t+=$_+3; "\%-".$_."s"} @len)." │".chr(10);
+my $sep_line_first = "┌".join("┬",map {("─"x($_+2))} @len)."┐".chr(10);
+my $sep_line = "├".join("┼",map {("─"x($_+2))} @len)."┤".chr(10);
+my $sep_line_last = "└".join("┴",map {("─"x($_+2))} @len)."┘".chr(10);
+*/
     $len = $o['_human']['len'];
     fseek($o['_human']['tmpfile'], 0);
 
+    $sep = $o['_human']['sep'];
+    $sep_top = (isset($o['sep_top']) ? $o['sep_top'] : $sep);
+    $sep_bottom = (isset($o['sep_bottom']) ? $o['sep_bottom'] : $sep);
+
     $sep_line = '';
+    $sep_line_top = '';
+    $sep_line_bottom = '';
     if (self::p('sep_line') !== '0') {
 
+       $count = 0;
       foreach ($len as $i) {
-        $sep_line .= $o['corner'].str_repeat($o['line'],$i+strlen($o['_human']['sep'])-1);
+       # NB 29.08.24 $sep = $o['_human']['sep'];
+       # NB 29.08.24 if ($count == 0) $sep = $sep_top;
+       # NB 29.08.24 if ($count == count($len)) $sep = $sep_bottom;
+
+        /*
+        if ($count == 0) {
+               $sep_line_top .=
+                       ( (isset($o['corner_left_top'])) ? $o['corner_left_top'] : $o['corner'])
+                       .str_repeat($o['line'],$i+mb_strlen($sep)-1)
+               ;
+        } else {
+               $sep_line_top .= $sep_top.str_repeat($o['line'],$i+mb_strlen($sep)-1);
+        }
+        */
+        $sep_line_top .=
+               ( ($count == 0 and isset($o['corner_left_top'])) ? $o['corner_left_top'] : $o['corner'])
+               .str_repeat($o['line'],$i+mb_strlen($sep_top)-1)
+        ;
+        $sep_line .=
+               (($count == 0 and isset($o['corner_left'])) ? $o['corner_left'] : $o['corner'])
+               .str_repeat($o['line'],$i+mb_strlen($sep)-1)
+               ;
+        $sep_line_bottom .=
+               ( ($count == 0 and isset($o['corner_left_bottom'])) ? $o['corner_left_bottom'] : $o['corner'])
+               .str_repeat($o['line'],$i+mb_strlen($sep_bottom)-1)
+               ;
+               $count++;
       }
-      $sep_line .= $o['corner'].$o['_human']['eol'];
+
+       $sep_line_top .=
+       (isset($o['corner_right_top']) ? $o['corner_right_top'] : $o['corner'])
+       .$o['_human']['eol']
+       ;       
+       $sep_line .=
+       (isset($o['corner_right']) ? $o['corner_right'] : $o['corner'])
+       .$o['_human']['eol']
+       ;       
+       $sep_line_bottom .=
+       (isset($o['corner_right_bottom']) ? $o['corner_right_bottom'] : $o['corner'])
+       .$o['_human']['eol']
+       ;       
+
     }
+    #bye($sep_line_top);
 
     $header = empty($o['_human']['head']) ? 0 : 1;
     $count = 0;
@@ -605,12 +658,18 @@ Class Out extends Nb {
       }
 
       # header
-      if (!$count) echo $sep_line;
+      if (!$count) {
+       echo $sep_line_top;
+      }
+
+      $sep = $o['_human']['sep'];
+      #if ($count == 0) $sep = $sep_top;
+      #if ($count == count($len)) $sep = $sep_bottom;
 
       echo ''
-        . ltrim($o['_human']['sep'])
-        . join($o['_human']['sep'],$values)
-        . rtrim($o['_human']['sep'])
+        . ltrim($sep)
+        . join($sep,$values)
+        . rtrim($sep)
       .$o['_human']['eol'];
 
       if ($header and !$count) echo $sep_line;
@@ -623,7 +682,8 @@ Class Out extends Nb {
     if ($header) $count--;
     if (!$count) return;
 
-    echo $sep_line;
+    echo $sep_line_bottom;
+    #if ($o['corner_left_bottom']) 
     if ($header) echo "$count Records\n";
 
   }
index 7bb002b7c888f67bed52aedebea2e9740d07d0be..ba268855eab486860a16856ed53eff0806021865 100644 (file)
@@ -1,10 +1,18 @@
 <?php
 if (!class_exists('out')) return;
 return [
-  'sep' => self::p('sep'," | "),
-  'corner' => self::p('corner',"+"),
+  'sep' => self::p('sep'," │ "),
+  'sep_top' => self::p('sep_top'," ┬ "),
+  'sep_bottom' => self::p('sep_bottom'," ┴ "),
+  'corner' => self::p('corner',"┼"),
+  'corner_left_top' => self::p('corner_left_top',"┌"),
+  'corner_right_top' => self::p('corner_right_top',"┐"),
+  'corner_left' => self::p('corner_left',"├"),
+  'corner_right' => self::p('corner_right',"┤"),
+  'corner_left_bottom' => self::p('corner_left_bottom',"└"),
+  'corner_right_bottom' => self::p('corner_right_bottom',"┘"),
   'eol' => self::p('eol',"\n"),
-  'line' => self::p('line',"-"),
+  'line' => self::p('line',""),
   'head' => 'out_human_head',
   'row' => 'out_human',
   'end' => 'out_human_end',