Commit bed158a 1 parent 3273570 commit bed158a Copy full SHA for bed158a
File tree 3 files changed +4
-33
lines changed
3 files changed +4
-33
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ if (file_exists($autoloadPathLocal)) {
11
11
require_once $ autoloadPathGlobal ;
12
12
}
13
13
14
- use function Differ \Parser \parseDiff ;
14
+ use function Differ \Parser \parse ;
15
15
16
16
$ doc = <<<DOC
17
17
Generate diff
29
29
30
30
$ args = Docopt::handle ($ doc , array ('version ' => 'Gendiff 1.0 ' ));
31
31
32
- parseDiff ($ args ['<firstFile> ' ], $ args ['<secondFile> ' ], $ args ['--format ' ]);
32
+ parse ($ args ['<firstFile> ' ], $ args ['<secondFile> ' ], $ args ['--format ' ]);
Original file line number Diff line number Diff line change 4
4
5
5
use Symfony \Component \Yaml \Yaml ;
6
6
7
- use function Differ \Parser \parseError ;
8
-
9
7
function getJson (string $ path ): array
10
8
{
11
9
$ content = getFileContent ($ path );
@@ -21,25 +19,11 @@ function getFileContent(string $path): string
21
19
{
22
20
$ dirPath = __DIR__ ;
23
21
24
- // Colors for beautiful :)
25
- $ normalColor = "\x1b[0m " ;
26
- $ redColor = "\x1b[41m " ;
27
-
28
22
if (str_starts_with ($ path , '/ ' )) {
29
23
$ fullPath = $ path ;
30
24
} else {
31
25
$ fullPath = "{$ dirPath }/../../ {$ path }" ;
32
26
}
33
27
34
- if (!file_exists ($ fullPath )) {
35
- $ errorMessage = <<<DOC
36
- {$ redColor }ERROR! {$ normalColor }
37
-
38
- File: " {$ fullPath }" don't exists!
39
- DOC ;
40
-
41
- parseError ($ errorMessage );
42
- }
43
-
44
28
return file_get_contents ($ fullPath );
45
29
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace Differ \Parser ;
4
4
5
- use JetBrains \PhpStorm \NoReturn ;
6
-
7
5
use function cli \line ;
8
6
use function Differ \Differ \genDiff ;
9
7
10
- #[NoReturn] function parse (string $ string ): void
11
- {
12
- line ('%s ' , $ string );
13
- exit ();
14
- }
15
-
16
- #[NoReturn] function parseDiff (string $ pathToFile1 , string $ pathToFile2 , string $ format ): void
8
+ function parse (string $ pathToFile1 , string $ pathToFile2 , string $ format ): void
17
9
{
18
10
$ resultString = genDiff ($ pathToFile1 , $ pathToFile2 , $ format );
19
- parse ($ resultString );
20
- }
21
-
22
- #[NoReturn] function parseError (string $ errorMessage ): void
23
- {
24
- parse ($ errorMessage );
11
+ line ($ resultString );
25
12
}
You can’t perform that action at this time.
0 commit comments