forked from xivapi/lodestone-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli
169 lines (154 loc) · 4.95 KB
/
cli
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env php
<?php
/**
*
* CLI tool to quickly test/debug specific API methods.
*
*/
// composer auto loader
require __DIR__ . '/vendor/autoload.php';
$api = new \Lodestone\Api();
print_r($argv);
if ($argc < 2) {
print("No arguments provided.\n");
return;
}
// Remove the cli file from the arguments array
array_shift($argv);
$cliCommandType = $argv[0];
switch ($cliCommandType) {
case "character":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected Character ID\n");
break;
}
print_r("Parsing character of {$argv[1]}...\n");
$results = $api->character()->get($argv[1]);
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "freecompany":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected FreeCompany ID\n");
break;
}
print_r("Parsing freecompany of {$argv[1]}...\n");
$results = $api->freecompany()->get($argv[1]);
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "pvpteam":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected PVP Team ID\n");
break;
}
print_r("Parsing pvp team of {$argv[1]}...\n");
$results = $api->pvpteam()->get($argv[1]);
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "linkshell":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected Linkshell ID\n");
break;
}
print_r("Parsing linkshell of {$argv[1]}...\n");
$results = $api->linkshell()->get($argv[1])->Results;
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "cwlinkshell":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected Linkshell ID\n");
break;
}
print_r("Parsing linkshell of {$argv[1]}...\n");
$results = $api->linkshell()->getCrossWorld($argv[1])->Results;
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "achievements":
if (!isset($argv[1])) {
print_r("INVALID ARGUMENT: Expected Linkshell ID\n");
break;
}
print_r("Parsing achievements of {$argv[1]}...\n");
$results = $api->character()->achievements($argv[1]);
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "banners":
$results = $api->lodestone()->banners();
if (isset($argv[1]) == "-file") {
$file = fopen("{$argv[2]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "leaderboards":
// Don't @me I know this is scuff.
switch ($argv[1]) {
case "feast":
$results = $api->leaderboards()->feast();
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "potd":
$results = $api->leaderboards()->ddPalaceOfTheDead();
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
case "hoh":
$results = $api->leaderboards()->ddHeavenOnHigh();
if (isset($argv[2]) == "-file") {
$file = fopen("{$argv[3]}.json", 'w');
fwrite($file, json_encode($results));
fclose($file);
break;
}
print_r($results);
break;
}
}