-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient
executable file
·56 lines (45 loc) · 1.55 KB
/
client
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
#!/usr/bin/env php
<?php
namespace Shimoning\DskCvs;
use Shimoning\DskCvs\Entities\Input;
use Shimoning\DskCvs\Entities\Options;
require_once __DIR__ . '/vendor/autoload.php';
// display welcome message
echo __NAMESPACE__ . " shell\n";
echo "-----\nexample:\n";
echo "\$options = new Entities\Options(['test' => true]);\n";
echo "\$input = new Entities\Input('YourUserId', 'YourPW);\n";
echo "\$recordsOrError = Client::requestCvsRecords(\$input, \$options);\n";
echo "\$recordsOrError->hasError();\n";
echo "\$recordsOrError->count();\n";
// load .env
if (\file_exists(__DIR__ . \DIRECTORY_SEPARATOR . '.env')) {
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
echo "-----\n'.env' loaded.\n";
echo "\nUSER_ID: " . (!empty($_ENV['USER_ID']) ? 'SET!' : 'missing...') . "\n";
echo " PW: " . (!empty($_ENV['PW']) ? 'SET!' : 'missing...') . "\n\n";
if (!empty($_ENV['USER_ID']) && !empty($_ENV['PW'])) {
echo "[ENV status] " . (!empty($_ENV['PW']) ? 'OK' : 'NG') . "\n\n";
}
if (!empty($_ENV['TEST'])) {
echo "** TEST mode **\n";
} else {
echo "!! PRODUCTION mode !!\n";
}
echo "-----\n";
}
// run shell
$sh = new \Psy\Shell();
$sh->addCode(sprintf("namespace %s;", __NAMESPACE__));
// set default
$options = new Options(['test' => $_ENV['TEST'] ?? true]);
$input = !empty($_ENV['USER_ID']) && !empty($_ENV['PW'])
? new Input($_ENV['USER_ID'], $_ENV['PW'])
: null;
$sh->setScopeVariables([
'options' => $options,
'input' => $input,
]);
$sh->run();
echo "\n-----\nBye.\n\n";