* See the License for the specific language governing permissions and * limitations under the License. */ require_once __DIR__ . '/cli/composer.php'; $cli = new League\CLImate\CLImate(); $cli->arguments->add(['file' => ['prefix' => 'f', 'longPrefix' => 'file', 'description' => 'Path to credentials file to parse', 'defaultValue' => null], 'help' => ['prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Show this help', 'defaultValue' => false, 'noValue' => true], 'section' => ['description' => '.edgerc section to create', 'defaultValue' => 'default']]); $cli->arguments->parse($_SERVER['argv']); if ($cli->arguments->get('help')) { $cli->usage(); exit; } define('HOME', $_SERVER['HOME']); define('EDGERC', realpath(HOME . '/.edgerc')); define('SECTION', $cli->arguments->get('section')); if (file_exists(EDGERC) && !is_writable(EDGERC) || !is_writable(HOME)) { $cli->to('error')->error("Unable to write to file " . EDGERC); exit(-1); } echo "After authorizing your client in the {OPEN} API Administration tool,\n"; echo "export the credentials and paste the contents of the export file below,\n"; echo "followed by control-D. (You may need to enter is twice)\n"; echo ">>> "; $inputStream = fopen('php://stdin', 'r+'); if (!($file = $cli->arguments->get('file'))) { $input = stream_get_contents($inputStream); } elseif (file_exists($file) && is_readable($file)) { $input = file_get_contents($file); } $cli = new League\CLImate\CLImate(); $cli->out(""); if (file_exists(EDGERC)) {