#!/usr/bin/env php
<?php

$filenameAutoloadLocal = __DIR__ . '/../vendor/autoload.php';
$filenameAutoloadVendor = __DIR__ . '/../../../autoload.php';

if (file_exists($filenameAutoloadLocal)) {
    require_once $filenameAutoloadLocal;
} elseif (file_exists($filenameAutoloadVendor)) {
    require_once $filenameAutoloadVendor;
} else {
    echo 'Missing autoload.php, run composer install.' . PHP_EOL;
    exit(1);
}

$allOption = getopt('', ['environment:', 'config-file:', 'api-key:']);

if (empty($allOption)) {
    \bunq\Util\InstallationUtil::interactiveInstall();
} else {
    \bunq\Util\InstallationUtil::automaticInstall(
            new \bunq\Util\BunqEnumApiEnvironmentType($allOption['environment']),
            $allOption['config-file'],
            $allOption['api-key'] ?? null
    );
}
