forked from isitnikov/m2-convert-patch-for-composer-install
-
Notifications
You must be signed in to change notification settings - Fork 6
/
convert-for-composer.php
executable file
·53 lines (41 loc) · 1004 Bytes
/
convert-for-composer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env php
<?php
require_once __DIR__ . '/src/Converter.php';
use Converter\Converter;
function showHelp()
{
echo <<<HELP_TEXT
Usage: php -f convert-for-composer.php [options] file [> new-file]
convert-for-composer.php [options] file [> new-file]
file path to source PATCH file
[options]
-h, --help Show help
-r Reverse mode. Convert composer format back to git
HELP_TEXT;
exit(0);
}
function parseArgs($args)
{
$filepath = null;
$r = false;
if (count($args) < 1) {
showHelp();
}
foreach ($args as $arg) {
if ($arg === '-h' || $arg === '--help') {
showHelp();
} elseif ($arg === '-r') {
$r = true;
} else {
$filepath = $arg;
}
}
return [$filepath, $r];
}
// Remove the first argument (the script name)
$args = array_slice($argv, 1);
$params = parseArgs($args);
$converter = new Converter($params);
$result = $converter->convert();
echo $result;
exit(0);