本文整理汇总了PHP中CLI::prompt方法的典型用法代码示例。如果您正苦于以下问题:PHP CLI::prompt方法的具体用法?PHP CLI::prompt怎么用?PHP CLI::prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLI
的用法示例。
在下文中一共展示了CLI::prompt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($parameters, $db)
{
if (sizeof($parameters) == 0 || $parameters[0] == "") {
CLI::out("Usage: |g|help <command>|n| To see a list of commands, use: |g|list", true);
}
$command = $parameters[0];
switch ($command) {
case "add":
if (isset($parameters[1])) {
$url = $parameters[1];
} else {
$validTypes = array("pilot", "corp", "alliance");
CLI::out("|g|You are now adding a feed with the quick feed creator(TM), if you already have a feed you want to add, use add <feed> instead.|n|");
retryekid:
$ekid = CLI::prompt("Do you have the EVE-KILL ID for the entity you want to add?", "yes");
if ($ekid != "yes" && $ekid != "no") {
CLI::out("|r|Error, call type is not supported. Please retry|n|");
goto retryekid;
}
if ($ekid == "no") {
$validTypes = array("pilotname", "corpname", "alliancename");
}
retryCall:
CLI::out("|g|Valid calls:|n| " . implode(", ", $validTypes));
$type = CLI::prompt("Type of call. |g|(Refer to the above list)|n|");
if (!in_array($type, $validTypes)) {
CLI::out("|r|Error, call type is not supported. Please retry|n|");
goto retryCall;
}
if ($ekid == "yes") {
$nameID = CLI::prompt("ID of entity you wish to add");
} else {
$nameID = urlencode(CLI::prompt("Name of the entity you with to add"));
}
retryApi:
$all = CLI::prompt("All Kills?", "yes");
if ($all != "yes" && $all != "no") {
CLI::out("|r|Error, call type is not supported. Please retry|n|");
goto retryApi;
}
$apiOnly = null;
if ($all == "yes") {
$apiOnly = "&allkills";
}
$domain = CLI::prompt("Enter URL of the killboard you're fetching from. |g|Ex. eve-kill.net|n|", "eve-kill.net");
$url = "http://{$domain}/?a=idfeed&{$type}={$nameID}{$apiOnly}";
}
if (filter_var($url, FILTER_VALIDATE_URL)) {
$db->execute("INSERT INTO zz_feeds (url, edkStyle) VALUES (:url, 1)", array(":url" => $url));
CLI::out("Now inserting |g|{$url}|n| to the database.", true);
} else {
CLI::out("|r|Invalid URL, please try again|n|", true);
}
break;
case "remove":
$id = NULL;
if (isset($parameters[1])) {
$id = $parameters[1];
}
if (is_null($id)) {
CLI::out("Please refer to feed list to show all the feeds you have added to your board. To remove one, use: |g|feed remove <id>|n|");
} elseif (!is_numeric($id)) {
CLI::out("|r|ID needs to be an int..|n|");
} else {
$url = $db->queryField("SELECT url FROM zz_feeds WHERE id = :id AND edkStyle = 1", "url", array(":id" => $id));
if (is_null($url)) {
CLI::out("|r|Feed is already removed.", true);
}
CLI::out("Removing feed: |g|{$url}");
$db->execute("DELETE FROM zz_feeds WHERE id = :id", array(":id" => $id));
}
break;
case "list":
$list = $db->query("SELECT * FROM zz_feeds WHERE edkStyle = 1");
foreach ($list as $url) {
CLI::out($url["id"] . "::|g|" . $url["url"]);
}
break;
case "fetch":
CLI::out("|g|Initiating feed fetching|n|");
$doSleep = false;
$size = 1;
$count = 1;
$feeds = $db->query("SELECT id, url, lastFetchTime FROM zz_feeds WHERE edkStyle IS true", array(), 0);
if (sizeof($feeds) > 1) {
$doSleep = true;
$size = sizeof($feeds);
}
foreach ($feeds as $feed) {
$url = $feed["url"];
$lastFetchTime = strtotime($feed["lastFetchTime"]) + 600;
$currentTime = time();
$insertCount = 0;
if ($lastFetchTime <= $currentTime) {
CLI::out("Fetching from |g|{$url}|n|");
try {
$data = self::fetchUrl($url);
$xml = new SimpleXMLElement($data, null, false, "", false);
$result = new \Pheal\Core\Result($xml);
$insertCount = self::processAPI($result, $db);
//.........这里部分代码省略.........