<?php // Clearer definition of Arguments vs. Flags require dirname(__DIR__) . '/vendor/autoload.php'; // v0.2.0 started to add a clearer definition between "flag" type options // and "argument" type options for those that may prefer it. // In Commando, flags are options that require a name when they are being // specified on the command line. Arguments are options that are not named in // this way. In the example below, '-f' and '--long' are described as "flags" // type options in Commando terms with the values 'value1' and 'value2' // respectively, whereas value3, value4, and value5 are described as "argument" // type options. // php argumentsVsFlags.php -f value1 --long value2 value3 value4 value5 $cmd = new Commando\Command(); $cmd->flag('f')->flag('l')->aka('long')->argument()->argument()->argument(); var_dump($cmd->getArgumentValues()); var_dump($cmd->getFlagValues()); // This is equivalent to... // $cmd = new Commando\Command(); // $cmd // ->option('f') // ->option('l') // ->aka('long') // ->option() // ->option() // ->option();
ini_set("memory_limit", "1024M"); // Turn on garbage collection gc_enable(); // Define the current dir define("BASEDIR", __DIR__); define("PLUGINDIR", __DIR__ . "/plugins/"); // In case we started from a different directory. chdir(BASEDIR); // Load all the vendor files require_once BASEDIR . "/vendor/autoload.php"; $cmd = new \Commando\Command(); // Define the logfiles location $cmd->option("c")->aka("config")->title("Path to configuration file")->describedAs("Defines the configuration file that the bot will use to run")->file(true)->require(); $cmd->option("ccp")->title("Install the ccp database")->describedAs("Installs the CCP database. Required before the bot can start properly")->boolean(); $cmd->option("conv")->aka("convert")->title("Converts a username/password login to token login")->describedAs("Converts the username/password login for Discord, to the new bot API token login"); $args = $cmd->getFlagValues(); // Define the path for the logfile $configPath = $args["c"] ? $args["c"] : \Exception("Error, config file not loaded"); // Bot start time $startTime = time(); // Load in the config require_once $configPath; // define the bots name define("BOTNAME", strtolower($config["bot"]["botName"])); // Conversion path triggered if ($args["conv"]) { $discord = new \Discord\Discord($config["discord"]["email"], $config["discord"]["password"]); $bot = Discord::createOauthApp($args["conv"], $config["bot"]["botName"]); $discord->convertToBot($args["conv"], $bot->id, $bot->secret); echo "Bot has been converted to the new Token API.."; exit;