From c017a81e30478cc4bbe59f1e4087cb3c2966f71a Mon Sep 17 00:00:00 2001 From: Osahenrumwen Aigbogun Date: Fri, 29 Dec 2023 18:04:18 +0100 Subject: [PATCH] Finally gotten the symlink refresh working --- src/BobDBuilder/Cmd/Project.php | 2 +- src/BobDBuilder/Cmd/Symlink.php | 16 +++++++++++++++- src/BobDBuilder/EnginePlug.php | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/BobDBuilder/Cmd/Project.php b/src/BobDBuilder/Cmd/Project.php index d8a4275..0cf93ec 100644 --- a/src/BobDBuilder/Cmd/Project.php +++ b/src/BobDBuilder/Cmd/Project.php @@ -52,7 +52,7 @@ public function create(): void if($tag == "--refresh-links") { $this->plug->write_info("Refreshing symlinks!"); - (new Symlink())->refresh_link(); + (new Symlink($this->plug))->refresh_link(); } if($tag == "--force-refresh") { diff --git a/src/BobDBuilder/Cmd/Symlink.php b/src/BobDBuilder/Cmd/Symlink.php index 6732433..12e33d4 100644 --- a/src/BobDBuilder/Cmd/Symlink.php +++ b/src/BobDBuilder/Cmd/Symlink.php @@ -15,6 +15,15 @@ class Symlink implements CmdLayout private EnginePlug $plug; private static string $link_db; + public function __construct(?EnginePlug $plug = null) + { + if(!$plug) + return; + + $this->plug = $plug; + $this->init_db(); + } + public function _init(EnginePlug $plug): void { $this->plug = $plug; @@ -26,13 +35,18 @@ public function _init(EnginePlug $plug): void public function _spin(): void { - self::$link_db = $this->plug->server->root . "symlinks.json"; + $this->init_db(); $this->htaccess(); $this->dir(); $this->file(); } + private function init_db() : void + { + self::$link_db = $this->plug->server->root . "symlinks.json"; + } + private function track_link(string $src, string $dest, string $link_type) : void { $new_link = [ diff --git a/src/BobDBuilder/EnginePlug.php b/src/BobDBuilder/EnginePlug.php index 2066b53..8faf4a4 100644 --- a/src/BobDBuilder/EnginePlug.php +++ b/src/BobDBuilder/EnginePlug.php @@ -216,6 +216,7 @@ private function arg(string $cmd_class, array $cmd, &$pipe, int|bool ...$value_i } public function write_info(string $message, array $opts = []) : void { + $opts['hide_current_cmd'] = true; $this->write($message, CmdOutType::INFO, $opts); }