Skip to content

Commit 8a8730b

Browse files
committed
fix: display error message to STDERR
1 parent d9c7ef8 commit 8a8730b

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/Command.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
final class Command
1111
{
12+
private const VERSION = '0.0.3';
13+
1214
/**
1315
* @param list<string> $argv
1416
*/
@@ -19,14 +21,26 @@ public function run(array $argv): void
1921
return;
2022
}
2123

24+
$option = $argv[1];
25+
26+
if ($option === '--help') {
27+
$this->printHelp();
28+
return;
29+
}
30+
31+
if ($option === '--version') {
32+
$this->printVersion();
33+
return;
34+
}
35+
2236
$filePath = $argv[1];
2337
if (!file_exists($filePath)) {
2438
echo "File not found: $filePath\n";
2539
return;
2640
}
2741

2842
$parser = new VariableParser();
29-
$content =file_get_contents($filePath);
43+
$content = file_get_contents($filePath);
3044
if ($content === false) {
3145
echo "Failed to read file: $filePath\n";
3246
return;
@@ -44,4 +58,9 @@ private function printHelp(): void
4458
echo " --help Display help information\n";
4559
echo " --version Show the version of the tool\n";
4660
}
61+
62+
private function printVersion(): void
63+
{
64+
echo "PHP Variable Hard Usage Analyzer, version " . self::VERSION . "\n";
65+
}
4766
}

0 commit comments

Comments
 (0)