From 033cb886acab735930bd5d4521cb58e723d2a1e3 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 24 Jun 2025 14:16:03 +0200 Subject: [PATCH] Add extra output to stow --- php/bin/stow | 4 ++++ php/includes/config.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/php/bin/stow b/php/bin/stow index 86fe351..dcd2d8b 100755 --- a/php/bin/stow +++ b/php/bin/stow @@ -25,7 +25,11 @@ $stowName = $parsed->get('stow-directory'); $stowPath = path($cwd, $stowName); $config = new config($stowPath, stow::CONFIG_FILE_NAME); +if ($config->configExists()) { + line('Config file exists, using config'); +} $targetPath = $config->get('targetPath', dirname($stowPath, 2)); +line(sprintf('Stowing %s to %s', $stowName, $targetPath)); if (!is_dir($stowPath)) { lexit("Directory '$stowName' does not exist", 1); diff --git a/php/includes/config.php b/php/includes/config.php index 86baf84..3ef709f 100644 --- a/php/includes/config.php +++ b/php/includes/config.php @@ -38,9 +38,14 @@ readonly class config private string $fileName = 'config.php', ) {} + public function configExists(): bool + { + return file_exists($this->getConfigFile()); + } + public function get(string $key, mixed $default = null): mixed { - if (!file_exists($this->getConfigFile())) { + if (!$this->configExists()) { return $default; } $config = include $this->getConfigFile();