Skip to content

Make it easy to debug with Placeholders #303

@llaville

Description

@llaville

I've finished my first Capt'n Plugin, and I've solved all my goals.

BTW, to be able to run it, we need a CaptainHook patched version, because I've added some new capabilities.

Second One -- this report

Note

It's not mandatory to run my plugin, but it's a real reading confort !

Current Behavior

Placeholder display only the type, not values !

pre-push:

Configuring Hook Plugin: \Bartlett\CaptainHookBinPlugin\BinPlugin
  Placeholder: env
  Placeholder: env
Do debug before hook pre-push runs
Do debug before action Static Analysis (with Mago) runs
 - Static Analysis (with Mago)                                       : done (0.13s)
Do debug after action Static Analysis (with Mago) runs
captainhook executed all actions successfully, took: 0.14s

Static Analysis (with Mago)
  Condition: \Bartlett\CaptainHookBinPlugin\Condition\PackageInstalled
  Applied: Package "carthage-software/mago" (with constraint "^1") installed
  Placeholder: env
  Placeholder: env
  Placeholder: env
  Placeholder: config
  cmd: MAGO_LOG=trace FORCE_COLOR=1 vendor/bin/mago --colors=auto lint
  command output:

... more ...

Expected Behavior

pre-push:

Configuring Hook Plugin: \Bartlett\CaptainHookBinPlugin\BinPlugin
  Placeholder: env (value-of: XDG_CONFIG_HOME, default: ~/.config)
  Placeholder: env (value-of: VENDOR_BIN_DIR, default: vendor/bin)
Do debug before hook pre-push runs
Do debug before action Static Analysis (with Mago) runs
 - Static Analysis (with Mago)                                       : done (0.30s)
Do debug after action Static Analysis (with Mago) runs
captainhook executed all actions successfully, took: 0.30s

Static Analysis (with Mago)
  Condition: \Bartlett\CaptainHookBinPlugin\Condition\PackageInstalled
  Applied: Package "carthage-software/mago" (with constraint "^1") installed
  Placeholder: env (value-of: MAGO_LOG, default: info)
  Placeholder: env (value-of: FORCE_COLOR, default: 0)
  Placeholder: env (value-of: XDG_BIN_HOME, default: NULL)
  Placeholder: config (value-of: plugin>>\Bartlett\CaptainHookBinPlugin\BinPlugin.auto-colors-flag, default: NULL)
  cmd: MAGO_LOG=trace FORCE_COLOR=1 vendor/bin/mago --colors=auto lint
  command output:

... more ...

My Patch suggestion

diff --git a/src/Runner/Action/Cli/Command/Formatter.php b/src/Runner/Action/Cli/Command/Formatter.php
index 83a4893..425b7a6 100644
--- a/src/Runner/Action/Cli/Command/Formatter.php
+++ b/src/Runner/Action/Cli/Command/Formatter.php
@@ -174,7 +174,14 @@ class Formatter
                 return '';
             }

-            $this->io->write('  <fg=cyan>Placeholder: ' . $placeholder . '</>', true, IO::VERBOSE);
+            $this->io->write(
+                vsprintf(
+                    '  <fg=cyan>Placeholder: %s (value-of: %s, default: %s)</>',
+                    [$placeholder, $options['value-of'], $options['default'] ?? 'NULL']
+                ),
+                true,
+                IO::VERBOSE
+            );
             $processor = $this->createPlaceholder($placeholder);
             $this->cache($rawPlaceholder, $processor->replacement($options));
         }

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions