Skip to content

Commit 82ef008

Browse files
committed
Update CLIParser to v0.2
1 parent 0db9e54 commit 82ef008

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
phpunit: "11"
5757
args: ""
5858
- version: "8.4"
59+
phpunit: "12"
60+
args: ""
61+
- version: "8.5"
5962
phpunit: "12"
6063
args: --display-deprecations --display-phpunit-deprecations
6164

@@ -94,6 +97,6 @@ jobs:
9497
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
9598
- uses: php-actions/composer@v6
9699
with:
97-
php_version: "8.4"
100+
php_version: "8.5"
98101
- name: Check compatibility
99102
run: composer rector

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php": ">=8.0",
1616
"ext-json": "*",
1717
"opis/json-schema": "^2.3",
18-
"nerou/cli-parser": "^0.1"
18+
"nerou/cli-parser": "^0.2"
1919
},
2020
"require-dev": {
2121
"humbug/box": "^3.16 || ^4.0",

src/validateJSONSchema.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
echo 'JSON Schema Validator @git-version@ by nerou GmbH'.PHP_EOL.PHP_EOL;
2020

21-
$cliArgs = new CLIParser($_SERVER['argv']);
21+
$cliArgs = new CLIParser($_SERVER['argv'], 'schema_file1.json schema_folder2 [...]');
2222
$cliArgs->setAllowedOptions([]);
2323
$cliArgs->setAllowedFlags([]);
2424
$cliArgs->setStrictMode(true);
2525
if(!$cliArgs->parse() || empty($cliArgs->getCommands())){
26-
echo 'usage: php '.basename(__FILE__).' schema_file1.json schema_folder2 [...]'.PHP_EOL;
26+
$cliArgs->printUsage();
2727
exit(2);
2828
}
2929

@@ -32,7 +32,7 @@
3232
try {
3333
$files = collectSchemaFiles($cliArgs->getCommands());
3434
} catch(\InvalidArgumentException $ex){
35-
echo "\033[31m".$ex->getMessage()."\033[0m".PHP_EOL;
35+
echo "\e[31m".$ex->getMessage()."\e[0m".PHP_EOL;
3636
exit(20);
3737
}
3838

@@ -59,7 +59,7 @@
5959
*/
6060
$json = json_decode($fileContent, flags: JSON_THROW_ON_ERROR);
6161
} catch(JsonException $ex){
62-
echo "[\033[31mSYNTAX ERROR\033[0m]".PHP_EOL;
62+
echo "[\e[31mSYNTAX ERROR\e[0m]".PHP_EOL;
6363
$errors++;
6464
continue;
6565
}
@@ -76,14 +76,14 @@
7676
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
7777
$errorMessage = str_replace('%24', '$', $errorMessage);
7878
$errorMessage = indent($errorMessage, $countChars * 2 + 4);
79-
echo "[\033[31mSCHEMA ERROR\033[0m]".PHP_EOL.$errorMessage.PHP_EOL;
79+
echo "[\e[31mSCHEMA ERROR\e[0m]".PHP_EOL.$errorMessage.PHP_EOL;
8080
$errors++;
8181
} else {
82-
echo "[\033[32mOK\033[0m]".PHP_EOL;
82+
echo "[\e[32mOK\e[0m]".PHP_EOL;
8383
}
8484
} catch(\ErrorException $ex){
8585
if(mb_strpos($ex->getMessage(), 'preg_match(): Compilation failed: ') === 0){
86-
echo "[\033[31mSYNTAX ERROR\033[0m]".PHP_EOL.indent($ex->getMessage(), $countChars * 2 + 4).PHP_EOL;
86+
echo "[\e[31mSYNTAX ERROR\e[0m]".PHP_EOL.indent($ex->getMessage(), $countChars * 2 + 4).PHP_EOL;
8787
$errors++;
8888
} else {
8989
throw $ex;

0 commit comments

Comments
 (0)