1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- include('api.1984tech.php');
- $tech = new OrwellWorld();
- //need at least 1 command line argument
- if ($argc >= 2) {
- $allowedOptions = array(
- '--run' => 'run all checks for local and remote domains lists',
- '--unique' => 'check domains list specified in DOMAINS_LIST option, for domain duplicates',
- '--unique-local' => 'check local domains.txt for domain duplicates',
- '--validity' => 'check domains list for for validity',
- '--validity-local' => 'check local domains list for for validity',
- '--sync' => 'sync 1984 local domains base with another list format: --sync [domains list file path or HTTP URL]',
- '--help' => 'show small help'
- );
- $option = $argv[1];
- if (isset($allowedOptions[$option])) {
- switch ($option) {
- case '--run':
- print($tech->runAllChecks());
- break;
- case '--unique':
- print($tech->uniqueCheck());
- break;
- case '--unique-local':
- print($tech->uniqueCheck(true));
- break;
- case '--validity':
- print($tech->validityCheck());
- break;
- case '--validity-local':
- print($tech->validityCheck(true));
- break;
- case '--sync':
- $customUrl = '';
- if (isset($argv[2])) {
- $customUrl = $argv[2];
- }
- print($tech->sync($customUrl));
- break;
- case '--help':
- print('Usage: php cli/check --option' . PHP_EOL);
- print('Available options:' . PHP_EOL);
- if (!empty($allowedOptions)) {
- foreach ($allowedOptions as $optionName => $optionDesc) {
- print($optionName . ' - ' . $optionDesc . PHP_EOL);
- }
- }
- break;
- }
- } else {
- print('Unknown command line option: ' . $option . PHP_EOL);
- }
- } else {
- //option requirement notification
- print('At least one option required.' . PHP_EOL);
- print('Usage: php cli/check --option' . PHP_EOL);
- print('For example: php cli/check --help' . PHP_EOL);
- }
|