From 2509df93d657440c49a2b1f48f587fe5a9b06979 Mon Sep 17 00:00:00 2001 From: Joe Tannenbaum Date: Wed, 18 Dec 2024 16:21:57 -0500 Subject: [PATCH] wip --- app/Commands/DetectCommand.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Commands/DetectCommand.php b/app/Commands/DetectCommand.php index aa1b8f0..5c9d056 100644 --- a/app/Commands/DetectCommand.php +++ b/app/Commands/DetectCommand.php @@ -8,16 +8,21 @@ class DetectCommand extends Command { - protected $signature = 'detect {code} {--debug} {--from-file=}'; + protected $signature = 'detect {path} {--debug} {--from-file=}'; protected $description = 'Detect things we care about in the current code'; public function handle(): void { - $code = $this->argument('code'); - if ($this->option('from-file')) { $code = file_get_contents(__DIR__ . '/../../tests/snippets/detect/' . $this->option('from-file') . '.php'); + } else { + try { + $code = file_get_contents($this->argument('path')); + } catch (\Exception $e) { + echo json_encode([]); + return; + } } $walker = new DetectWalker($code, (bool) $this->option('debug'));