repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb.load
public function load() { $matchesInfo = $this->_getMatchesIdsFromMatches(); $matchesIds = array(); foreach ($matchesInfo as $matchInfo) { array_push($matchesIds, $matchInfo['match_id']); } if (count($matchesIds) === 0) { return array(); } ...
php
public function load() { $matchesInfo = $this->_getMatchesIdsFromMatches(); $matchesIds = array(); foreach ($matchesInfo as $matchInfo) { array_push($matchesIds, $matchInfo['match_id']); } if (count($matchesIds) === 0) { return array(); } ...
[ "public", "function", "load", "(", ")", "{", "$", "matchesInfo", "=", "$", "this", "->", "_getMatchesIdsFromMatches", "(", ")", ";", "$", "matchesIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "matchesInfo", "as", "$", "matchInfo", ")", "{", "...
Load matches from db Possible filters: league_id, hero_id, account_id, start_at_match_id Also matches_requested used as LIMIT @return Match[]
[ "Load", "matches", "from", "db" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L59-L110
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb.delete
public function delete(array $ids) { if (!count($ids)) { return; } $ids_str = implode(',', $ids); $db = Db::obtain(); $slots = $db->fetchArrayPDO( 'SELECT id FROM ' . Db::realTablename('slots') . ' WHERE match_id IN (' . $ids_str . ')', arr...
php
public function delete(array $ids) { if (!count($ids)) { return; } $ids_str = implode(',', $ids); $db = Db::obtain(); $slots = $db->fetchArrayPDO( 'SELECT id FROM ' . Db::realTablename('slots') . ' WHERE match_id IN (' . $ids_str . ')', arr...
[ "public", "function", "delete", "(", "array", "$", "ids", ")", "{", "if", "(", "!", "count", "(", "$", "ids", ")", ")", "{", "return", ";", "}", "$", "ids_str", "=", "implode", "(", "','", ",", "$", "ids", ")", ";", "$", "db", "=", "Db", "::"...
Delete matches info from db @param array $ids
[ "Delete", "matches", "info", "from", "db" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L116-L139
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._loadSlotsInfo
private function _loadSlotsInfo(array $matchesIds) { $db = Db::obtain(); $slots_query = 'SELECT * FROM ' . Db::realTablename('slots') . ' WHERE match_id IN (' . implode( ',', $matchesIds ) . ')'; return $db->fetchArrayPDO($slots_query, array()); }
php
private function _loadSlotsInfo(array $matchesIds) { $db = Db::obtain(); $slots_query = 'SELECT * FROM ' . Db::realTablename('slots') . ' WHERE match_id IN (' . implode( ',', $matchesIds ) . ')'; return $db->fetchArrayPDO($slots_query, array()); }
[ "private", "function", "_loadSlotsInfo", "(", "array", "$", "matchesIds", ")", "{", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "$", "slots_query", "=", "'SELECT * FROM '", ".", "Db", "::", "realTablename", "(", "'slots'", ")", ".", "' WHERE match...
Load data about slots from "slots" table. Array of the matches ids used as filter @param array $matchesIds @return array
[ "Load", "data", "about", "slots", "from", "slots", "table", ".", "Array", "of", "the", "matches", "ids", "used", "as", "filter" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L148-L156
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._loadPicksBansInfo
private function _loadPicksBansInfo(array $matchesIds) { $db = Db::obtain(); $picksBansQuery = 'SELECT * FROM ' . Db::realTablename('picks_bans') . ' WHERE match_id IN (' . implode( ',', $matchesIds ) . ')'; $picksBansInfo = $db->fetchArrayPDO($picksBansQuery,...
php
private function _loadPicksBansInfo(array $matchesIds) { $db = Db::obtain(); $picksBansQuery = 'SELECT * FROM ' . Db::realTablename('picks_bans') . ' WHERE match_id IN (' . implode( ',', $matchesIds ) . ')'; $picksBansInfo = $db->fetchArrayPDO($picksBansQuery,...
[ "private", "function", "_loadPicksBansInfo", "(", "array", "$", "matchesIds", ")", "{", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "$", "picksBansQuery", "=", "'SELECT * FROM '", ".", "Db", "::", "realTablename", "(", "'picks_bans'", ")", ".", "'...
Load data about picks and bans from "picks_bans" table. Array of the matches ids used as filter. Data is formatted like <code> Array ( [match_id] => Array ( [0] => Array( [id] => int [match_id] => match_id [is_pick] => 0/1 [hero_id] => hero_id [team] => 0/1 [order] => 0/1 ) ... ) ... ) </code> @param array $matchesIds ...
[ "Load", "data", "about", "picks", "and", "bans", "from", "picks_bans", "table", ".", "Array", "of", "the", "matches", "ids", "used", "as", "filter", ".", "Data", "is", "formatted", "like", "<code", ">", "Array", "(", "[", "match_id", "]", "=", ">", "Ar...
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L181-L198
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._loadAbilityUpgradesInfo
private function _loadAbilityUpgradesInfo(array $slotsIds) { $db = Db::obtain(); $abilitiesUpgradeQuery = 'SELECT * FROM ' . Db::realTablename('ability_upgrades') . ' WHERE slot_id IN (' . implode( ',', $slotsIds ) . ') ORDER BY slot_id, level ASC'; $abilities...
php
private function _loadAbilityUpgradesInfo(array $slotsIds) { $db = Db::obtain(); $abilitiesUpgradeQuery = 'SELECT * FROM ' . Db::realTablename('ability_upgrades') . ' WHERE slot_id IN (' . implode( ',', $slotsIds ) . ') ORDER BY slot_id, level ASC'; $abilities...
[ "private", "function", "_loadAbilityUpgradesInfo", "(", "array", "$", "slotsIds", ")", "{", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "$", "abilitiesUpgradeQuery", "=", "'SELECT * FROM '", ".", "Db", "::", "realTablename", "(", "'ability_upgrades'", ...
Load data about ability upgrades from "ability_upgrades" table. Array of the slots ids used as filter. Data is formatted like <code> Array ( [slot_id] => Array ( [0] => Array ( [slot_id] => slot_id [ability] => ability identifier [time] => timestamp from the match start time [level] => hero level ) ... ) ... ) </code> ...
[ "Load", "data", "about", "ability", "upgrades", "from", "ability_upgrades", "table", ".", "Array", "of", "the", "slots", "ids", "used", "as", "filter", ".", "Data", "is", "formatted", "like", "<code", ">", "Array", "(", "[", "slot_id", "]", "=", ">", "Ar...
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L221-L239
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._loadAdditionalUnitsInfo
private function _loadAdditionalUnitsInfo(array $slotsIds) { $db = Db::obtain(); $additionalUnitsQuery = 'SELECT * FROM ' . Db::realTablename('additional_units') . ' WHERE slot_id IN (' . implode( ',', $slotsIds ) . ')'; $additionalUnitsInfo = $db->fetchArrayP...
php
private function _loadAdditionalUnitsInfo(array $slotsIds) { $db = Db::obtain(); $additionalUnitsQuery = 'SELECT * FROM ' . Db::realTablename('additional_units') . ' WHERE slot_id IN (' . implode( ',', $slotsIds ) . ')'; $additionalUnitsInfo = $db->fetchArrayP...
[ "private", "function", "_loadAdditionalUnitsInfo", "(", "array", "$", "slotsIds", ")", "{", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "$", "additionalUnitsQuery", "=", "'SELECT * FROM '", ".", "Db", "::", "realTablename", "(", "'additional_units'", ...
Load data about additional units from "additional_units" table. Array of the slots ids used as filter. Data is formatted like <code> Array ( [slot_id] => Array ( [slot_id] => slot_id [unitname] => spirit_bear (example) [item_0] => item_id [item_1] => item_id [item_2] => item_id [item_3] => item_id [item_4] => item_id [...
[ "Load", "data", "about", "additional", "units", "from", "additional_units", "table", ".", "Array", "of", "the", "slots", "ids", "used", "as", "filter", ".", "Data", "is", "formatted", "like", "<code", ">", "Array", "(", "[", "slot_id", "]", "=", ">", "Ar...
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L263-L279
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._getMatchesIdsFromMatches
private function _getMatchesIdsFromMatches() { $_matchesIdsFromSlots = $this->_getMatchesIdsFromSlots(); $db = Db::obtain(); // basic matches data $matchesQuery = 'SELECT * FROM ' . Db::realTablename('matches') . ''; $where = ''; $data = array(); if (null !==...
php
private function _getMatchesIdsFromMatches() { $_matchesIdsFromSlots = $this->_getMatchesIdsFromSlots(); $db = Db::obtain(); // basic matches data $matchesQuery = 'SELECT * FROM ' . Db::realTablename('matches') . ''; $where = ''; $data = array(); if (null !==...
[ "private", "function", "_getMatchesIdsFromMatches", "(", ")", "{", "$", "_matchesIdsFromSlots", "=", "$", "this", "->", "_getMatchesIdsFromSlots", "(", ")", ";", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "// basic matches data", "$", "matchesQuery", ...
Get info about matches from the "matches" table Use matches ids from slots table as additional filter @return array
[ "Get", "info", "about", "matches", "from", "the", "matches", "table", "Use", "matches", "ids", "from", "slots", "table", "as", "additional", "filter" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L286-L332
kronusme/dota2-api
includes/Mappers/MatchesMapperDb.php
MatchesMapperDb._getMatchesIdsFromSlots
private function _getMatchesIdsFromSlots() { $db = Db::obtain(); $forSlots = 'SELECT match_id ' . Db::realTablename('FROM slots') . ''; $whereForSlots = ''; $dataForSlots = array(); if (null !== $this->getHeroId()) { $whereForSlots .= 'hero_id = ? AND '; ...
php
private function _getMatchesIdsFromSlots() { $db = Db::obtain(); $forSlots = 'SELECT match_id ' . Db::realTablename('FROM slots') . ''; $whereForSlots = ''; $dataForSlots = array(); if (null !== $this->getHeroId()) { $whereForSlots .= 'hero_id = ? AND '; ...
[ "private", "function", "_getMatchesIdsFromSlots", "(", ")", "{", "$", "db", "=", "Db", "::", "obtain", "(", ")", ";", "$", "forSlots", "=", "'SELECT match_id '", ".", "Db", "::", "realTablename", "(", "'FROM slots'", ")", ".", "''", ";", "$", "whereForSlot...
Get matches ids with provided hero_id or account_id (query for "slots" table) @return array
[ "Get", "matches", "ids", "with", "provided", "hero_id", "or", "account_id", "(", "query", "for", "slots", "table", ")" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/MatchesMapperDb.php#L338-L363
kronusme/dota2-api
includes/Models/Slot.php
Slot.removeAdditionalUnitItem
public function removeAdditionalUnitItem($item_id) { foreach ($this->_additional_unit_items as $k => $id) { if ($id === $item_id) { unset($this->_additional_unit_items[$k]); break; } } return $this; }
php
public function removeAdditionalUnitItem($item_id) { foreach ($this->_additional_unit_items as $k => $id) { if ($id === $item_id) { unset($this->_additional_unit_items[$k]); break; } } return $this; }
[ "public", "function", "removeAdditionalUnitItem", "(", "$", "item_id", ")", "{", "foreach", "(", "$", "this", "->", "_additional_unit_items", "as", "$", "k", "=>", "$", "id", ")", "{", "if", "(", "$", "id", "===", "$", "item_id", ")", "{", "unset", "("...
Remove item from additional unit items @param int $item_id @return slot
[ "Remove", "item", "from", "additional", "unit", "items" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Models/Slot.php#L198-L207
kronusme/dota2-api
includes/Mappers/PlayerMapperDb.php
PlayerMapperDb.save
public function save(Player $player) { if (self::playerExists($player->get('steamid'))) { $this->update($player); } else { $this->insert($player); } }
php
public function save(Player $player) { if (self::playerExists($player->get('steamid'))) { $this->update($player); } else { $this->insert($player); } }
[ "public", "function", "save", "(", "Player", "$", "player", ")", "{", "if", "(", "self", "::", "playerExists", "(", "$", "player", "->", "get", "(", "'steamid'", ")", ")", ")", "{", "$", "this", "->", "update", "(", "$", "player", ")", ";", "}", ...
Determines whether the player should be inserted or updated in the db @param Player $player
[ "Determines", "whether", "the", "player", "should", "be", "inserted", "or", "updated", "in", "the", "db" ]
train
https://github.com/kronusme/dota2-api/blob/bbc512369ccb1490804d0e4ed13f5b58f20ca004/includes/Mappers/PlayerMapperDb.php#L58-L65
inhere/php-console
src/Application.php
Application.controller
public function controller(string $name, $class = null, $option = null) { if (\is_string($option)) { $option = [ 'description' => $option, ]; } $this->getRouter()->addGroup($name, $class, (array)$option); return $this; }
php
public function controller(string $name, $class = null, $option = null) { if (\is_string($option)) { $option = [ 'description' => $option, ]; } $this->getRouter()->addGroup($name, $class, (array)$option); return $this; }
[ "public", "function", "controller", "(", "string", "$", "name", ",", "$", "class", "=", "null", ",", "$", "option", "=", "null", ")", "{", "if", "(", "\\", "is_string", "(", "$", "option", ")", ")", "{", "$", "option", "=", "[", "'description'", "=...
{@inheritdoc}
[ "{" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L26-L37
inhere/php-console
src/Application.php
Application.addGroup
public function addGroup(string $name, $controller = null, $option = null) { return $this->controller($name, $controller, $option); }
php
public function addGroup(string $name, $controller = null, $option = null) { return $this->controller($name, $controller, $option); }
[ "public", "function", "addGroup", "(", "string", "$", "name", ",", "$", "controller", "=", "null", ",", "$", "option", "=", "null", ")", "{", "return", "$", "this", "->", "controller", "(", "$", "name", ",", "$", "controller", ",", "$", "option", ")"...
add group/controller @inheritdoc @see controller()
[ "add", "group", "/", "controller" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L44-L47
inhere/php-console
src/Application.php
Application.addController
public function addController(string $name, $class = null, $option = null) { return $this->controller($name, $class, $option); }
php
public function addController(string $name, $class = null, $option = null) { return $this->controller($name, $class, $option); }
[ "public", "function", "addController", "(", "string", "$", "name", ",", "$", "class", "=", "null", ",", "$", "option", "=", "null", ")", "{", "return", "$", "this", "->", "controller", "(", "$", "name", ",", "$", "class", ",", "$", "option", ")", "...
{@inheritdoc} @see controller() @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L54-L57
inhere/php-console
src/Application.php
Application.command
public function command(string $name, $handler = null, $option = null) { if (\is_string($option)) { $option = [ 'description' => $option, ]; } $this->getRouter()->addCommand($name, $handler, (array)$option); return $this; }
php
public function command(string $name, $handler = null, $option = null) { if (\is_string($option)) { $option = [ 'description' => $option, ]; } $this->getRouter()->addCommand($name, $handler, (array)$option); return $this; }
[ "public", "function", "command", "(", "string", "$", "name", ",", "$", "handler", "=", "null", ",", "$", "option", "=", "null", ")", "{", "if", "(", "\\", "is_string", "(", "$", "option", ")", ")", "{", "$", "option", "=", "[", "'description'", "=>...
{@inheritdoc}
[ "{" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L90-L101
inhere/php-console
src/Application.php
Application.addCommand
public function addCommand(string $name, $handler = null, $option = null): self { return $this->command($name, $handler, $option); }
php
public function addCommand(string $name, $handler = null, $option = null): self { return $this->command($name, $handler, $option); }
[ "public", "function", "addCommand", "(", "string", "$", "name", ",", "$", "handler", "=", "null", ",", "$", "option", "=", "null", ")", ":", "self", "{", "return", "$", "this", "->", "command", "(", "$", "name", ",", "$", "handler", ",", "$", "opti...
add command @inheritdoc @see command()
[ "add", "command" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L108-L111
inhere/php-console
src/Application.php
Application.registerCommands
public function registerCommands(string $namespace, string $basePath): self { $length = \strlen($basePath) + 1; $iterator = Helper::directoryIterator($basePath, $this->getFileFilter()); foreach ($iterator as $file) { $class = $namespace . '\\' . \substr($file, $length, -4); ...
php
public function registerCommands(string $namespace, string $basePath): self { $length = \strlen($basePath) + 1; $iterator = Helper::directoryIterator($basePath, $this->getFileFilter()); foreach ($iterator as $file) { $class = $namespace . '\\' . \substr($file, $length, -4); ...
[ "public", "function", "registerCommands", "(", "string", "$", "namespace", ",", "string", "$", "basePath", ")", ":", "self", "{", "$", "length", "=", "\\", "strlen", "(", "$", "basePath", ")", "+", "1", ";", "$", "iterator", "=", "Helper", "::", "direc...
auto register commands from a dir. ```php $app->registerCommands('SwagPhp\Command', dirname(__DIR__) . '/src/Command'); ``` @param string $namespace @param string $basePath @return $this @throws \InvalidArgumentException
[ "auto", "register", "commands", "from", "a", "dir", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L143-L154
inhere/php-console
src/Application.php
Application.registerGroups
public function registerGroups(string $namespace, string $basePath): self { $length = \strlen($basePath) + 1; $iterator = Helper::directoryIterator($basePath, $this->getFileFilter()); foreach ($iterator as $file) { $class = $namespace . '\\' . \substr($file, $length, -4); ...
php
public function registerGroups(string $namespace, string $basePath): self { $length = \strlen($basePath) + 1; $iterator = Helper::directoryIterator($basePath, $this->getFileFilter()); foreach ($iterator as $file) { $class = $namespace . '\\' . \substr($file, $length, -4); ...
[ "public", "function", "registerGroups", "(", "string", "$", "namespace", ",", "string", "$", "basePath", ")", ":", "self", "{", "$", "length", "=", "\\", "strlen", "(", "$", "basePath", ")", "+", "1", ";", "$", "iterator", "=", "Helper", "::", "directo...
auto register controllers from a dir. @param string $namespace @param string $basePath @return $this @throws \InvalidArgumentException
[ "auto", "register", "controllers", "from", "a", "dir", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L163-L174
inhere/php-console
src/Application.php
Application.runCommand
protected function runCommand(string $name, $handler, array $options) { if (\is_object($handler) && \method_exists($handler, '__invoke')) { if ($this->input->getSameOpt(['h', 'help'])) { $desc = $options['description'] ?? 'No command description message'; return ...
php
protected function runCommand(string $name, $handler, array $options) { if (\is_object($handler) && \method_exists($handler, '__invoke')) { if ($this->input->getSameOpt(['h', 'help'])) { $desc = $options['description'] ?? 'No command description message'; return ...
[ "protected", "function", "runCommand", "(", "string", "$", "name", ",", "$", "handler", ",", "array", "$", "options", ")", "{", "if", "(", "\\", "is_object", "(", "$", "handler", ")", "&&", "\\", "method_exists", "(", "$", "handler", ",", "'__invoke'", ...
run a independent command @param string $name Command name @param \Closure|string $handler Command class @param array $options @return mixed @throws \InvalidArgumentException
[ "run", "a", "independent", "command" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L248-L276
inhere/php-console
src/Application.php
Application.runAction
protected function runAction(string $group, string $action, $handler, array $options, bool $standAlone = false) { /** @var Controller $handler */ if (\is_string($handler)) { $class = $handler; if (!\class_exists($class)) { Helper::throwInvalidArgument('The co...
php
protected function runAction(string $group, string $action, $handler, array $options, bool $standAlone = false) { /** @var Controller $handler */ if (\is_string($handler)) { $class = $handler; if (!\class_exists($class)) { Helper::throwInvalidArgument('The co...
[ "protected", "function", "runAction", "(", "string", "$", "group", ",", "string", "$", "action", ",", "$", "handler", ",", "array", "$", "options", ",", "bool", "$", "standAlone", "=", "false", ")", "{", "/** @var Controller $handler */", "if", "(", "\\", ...
Execute an action in a group command(controller) @param string $group The group name @param string $action Command method, no suffix @param mixed $handler The controller class or object @param array $options @param bool $standAlone @return mixed @throws \ReflectionException
[ "Execute", "an", "action", "in", "a", "group", "command", "(", "controller", ")" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Application.php#L288-L320
inhere/php-console
examples/Controller/ShowController.php
ShowController.splitLineCommand
public function splitLineCommand(): int { $this->output->splitLine('', '=', $this->getSameOpt(['w', 'width'], 0)); $this->output->splitLine('split Line', '-', $this->getSameOpt(['w', 'width'], 0)); $this->output->splitLine('split 中文 Line', '-', $this->getSameOpt(['w', 'width'], 0)); ...
php
public function splitLineCommand(): int { $this->output->splitLine('', '=', $this->getSameOpt(['w', 'width'], 0)); $this->output->splitLine('split Line', '-', $this->getSameOpt(['w', 'width'], 0)); $this->output->splitLine('split 中文 Line', '-', $this->getSameOpt(['w', 'width'], 0)); ...
[ "public", "function", "splitLineCommand", "(", ")", ":", "int", "{", "$", "this", "->", "output", "->", "splitLine", "(", "''", ",", "'='", ",", "$", "this", "->", "getSameOpt", "(", "[", "'w'", ",", "'width'", "]", ",", "0", ")", ")", ";", "$", ...
output format message: splitLine @options -w, --width WIDTH The split line width. default is current screen width.
[ "output", "format", "message", ":", "splitLine" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L64-L71
inhere/php-console
examples/Controller/ShowController.php
ShowController.panelCommand
public function panelCommand(): void { $data = [ 'application version' => '1.2.0', 'system version' => '5.2.3', 'key' => 'value ...', 'a only value message text', ]; Show::panel($data, 'panel show', [ 'borderCh...
php
public function panelCommand(): void { $data = [ 'application version' => '1.2.0', 'system version' => '5.2.3', 'key' => 'value ...', 'a only value message text', ]; Show::panel($data, 'panel show', [ 'borderCh...
[ "public", "function", "panelCommand", "(", ")", ":", "void", "{", "$", "data", "=", "[", "'application version'", "=>", "'1.2.0'", ",", "'system version'", "=>", "'5.2.3'", ",", "'key'", "=>", "'value ...'", ",", "'a only value message text'", ",", "]", ";", "...
output format message: panel
[ "output", "format", "message", ":", "panel" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L94-L117
inhere/php-console
examples/Controller/ShowController.php
ShowController.colorCommand
public function colorCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return 0; } $this->write('color style text output:'); $styles = $this->output->getStyle()->getStyleNames(); ...
php
public function colorCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return 0; } $this->write('color style text output:'); $styles = $this->output->getStyle()->getStyleNames(); ...
[ "public", "function", "colorCommand", "(", ")", ":", "int", "{", "if", "(", "!", "$", "this", "->", "output", "->", "supportColor", "(", ")", ")", "{", "$", "this", "->", "write", "(", "'Current terminal is not support output color text.'", ")", ";", "return...
a example for use color text output by Style::class @usage {fullCommand} @return int
[ "a", "example", "for", "use", "color", "text", "output", "by", "Style", "::", "class" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L124-L139
inhere/php-console
examples/Controller/ShowController.php
ShowController.colorLiteCommand
public function colorLiteCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return -2; } $this->output->startBuffer(); foreach (Color::getStyles() as $style) { $this->output-...
php
public function colorLiteCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return -2; } $this->output->startBuffer(); foreach (Color::getStyles() as $style) { $this->output-...
[ "public", "function", "colorLiteCommand", "(", ")", ":", "int", "{", "if", "(", "!", "$", "this", "->", "output", "->", "supportColor", "(", ")", ")", "{", "$", "this", "->", "write", "(", "'Current terminal is not support output color text.'", ")", ";", "re...
a example for use color text output by Style::class
[ "a", "example", "for", "use", "color", "text", "output", "by", "Style", "::", "class" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L144-L160
inhere/php-console
examples/Controller/ShowController.php
ShowController.blockMsgCommand
public function blockMsgCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return 0; } $this->write('block message:'); foreach (Show::getBlockMethods() as $type) { $this->ou...
php
public function blockMsgCommand(): int { if (!$this->output->supportColor()) { $this->write('Current terminal is not support output color text.'); return 0; } $this->write('block message:'); foreach (Show::getBlockMethods() as $type) { $this->ou...
[ "public", "function", "blockMsgCommand", "(", ")", ":", "int", "{", "if", "(", "!", "$", "this", "->", "output", "->", "supportColor", "(", ")", ")", "{", "$", "this", "->", "write", "(", "'Current terminal is not support output color text.'", ")", ";", "ret...
output block message text @return int
[ "output", "block", "message", "text" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L166-L181
inhere/php-console
examples/Controller/ShowController.php
ShowController.highlightCommand
public function highlightCommand($in): void { // $file = $this->app->getRootPath() . '/examples/routes.php'; $file = $this->app->getRootPath() . '/src/Utils/Show.php'; $src = \file_get_contents($file); $code = Highlighter::create()->highlight($src, $in->getBoolOpt('ln')); ...
php
public function highlightCommand($in): void { // $file = $this->app->getRootPath() . '/examples/routes.php'; $file = $this->app->getRootPath() . '/src/Utils/Show.php'; $src = \file_get_contents($file); $code = Highlighter::create()->highlight($src, $in->getBoolOpt('ln')); ...
[ "public", "function", "highlightCommand", "(", "$", "in", ")", ":", "void", "{", "// $file = $this->app->getRootPath() . '/examples/routes.php';", "$", "file", "=", "$", "this", "->", "app", "->", "getRootPath", "(", ")", ".", "'/src/Utils/Show.php'", ";", "$", "s...
a example for highlight code @options --ln Display with line number @param Input $in
[ "a", "example", "for", "highlight", "code" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L217-L226
inhere/php-console
examples/Controller/ShowController.php
ShowController.helpPanelCommand
public function helpPanelCommand(): void { Show::helpPanel([ HelpPanel::DESC => 'a help panel description text. (help panel show)', HelpPanel::USAGE => 'a usage text', HelpPanel::ARGUMENTS => [ 'arg1' => 'arg1 description', 'arg2' ...
php
public function helpPanelCommand(): void { Show::helpPanel([ HelpPanel::DESC => 'a help panel description text. (help panel show)', HelpPanel::USAGE => 'a usage text', HelpPanel::ARGUMENTS => [ 'arg1' => 'arg1 description', 'arg2' ...
[ "public", "function", "helpPanelCommand", "(", ")", ":", "void", "{", "Show", "::", "helpPanel", "(", "[", "HelpPanel", "::", "DESC", "=>", "'a help panel description text. (help panel show)'", ",", "HelpPanel", "::", "USAGE", "=>", "'a usage text'", ",", "HelpPanel...
output format message: helpPanel
[ "output", "format", "message", ":", "helpPanel" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L231-L247
inhere/php-console
examples/Controller/ShowController.php
ShowController.jsonCommand
public function jsonCommand(): void { $data = [ [ 'id' => 1, 'name' => 'john', 'status' => 2, 'email' => 'john@email.com', ], [ 'id' => 2, 'name' => 'tom', ...
php
public function jsonCommand(): void { $data = [ [ 'id' => 1, 'name' => 'john', 'status' => 2, 'email' => 'john@email.com', ], [ 'id' => 2, 'name' => 'tom', ...
[ "public", "function", "jsonCommand", "(", ")", ":", "void", "{", "$", "data", "=", "[", "[", "'id'", "=>", "1", ",", "'name'", "=>", "'john'", ",", "'status'", "=>", "2", ",", "'email'", "=>", "'john@email.com'", ",", "]", ",", "[", "'id'", "=>", "...
output format message: dump
[ "output", "format", "message", ":", "dump" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ShowController.php#L280-L311
inhere/php-console
examples/demo/cli-spinner.php
Status.spinner
public static function spinner() { static $spinner = 0; static $mtime = null; // static $chars = '-\|/'; static $chars = '-.*.-'; $now = microtime(true); if (null === $mtime || ($mtime < $now - 0.1)) { $mtime = $now; self::clearLine(); ...
php
public static function spinner() { static $spinner = 0; static $mtime = null; // static $chars = '-\|/'; static $chars = '-.*.-'; $now = microtime(true); if (null === $mtime || ($mtime < $now - 0.1)) { $mtime = $now; self::clearLine(); ...
[ "public", "static", "function", "spinner", "(", ")", "{", "static", "$", "spinner", "=", "0", ";", "static", "$", "mtime", "=", "null", ";", "// static $chars = '-\\|/';", "static", "$", "chars", "=", "'-.*.-'", ";", "$", "now", "=", "microtime", "(", "t...
Spinner that updates every call up to 4 per second .*.
[ "Spinner", "that", "updates", "every", "call", "up", "to", "4", "per", "second" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/demo/cli-spinner.php#L23-L42
inhere/php-console
examples/demo/cli-spinner.php
Status.prompt
public static function prompt($prompt, $masked=false, $limit=100) { echo "$prompt: "; if ($masked) { `stty -echo`; // disable shell echo } $buffer = ''; $char = ""; $f = fopen('php://stdin', 'r'); while (strlen($buffer) < $limit) { $cha...
php
public static function prompt($prompt, $masked=false, $limit=100) { echo "$prompt: "; if ($masked) { `stty -echo`; // disable shell echo } $buffer = ''; $char = ""; $f = fopen('php://stdin', 'r'); while (strlen($buffer) < $limit) { $cha...
[ "public", "static", "function", "prompt", "(", "$", "prompt", ",", "$", "masked", "=", "false", ",", "$", "limit", "=", "100", ")", "{", "echo", "\"$prompt: \"", ";", "if", "(", "$", "masked", ")", "{", "`stty -echo`", ";", "// disable shell echo", "}", ...
Prompts the user for input. Optionally masking it. @param string $prompt The prompt to show the user @param bool $masked If true, the users input will not be shown. e.g. password input @param int $limit The maximum amount of input to accept @return string
[ "Prompts", "the", "user", "for", "input", ".", "Optionally", "masking", "it", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/demo/cli-spinner.php#L61-L82
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.findCommand
protected function findCommand(): void { if (!isset($this->args[0])) { return; } $newArgs = []; foreach ($this->args as $key => $value) { if ($key === 0) { $this->command = \trim($value); } elseif (\is_int($key)) { ...
php
protected function findCommand(): void { if (!isset($this->args[0])) { return; } $newArgs = []; foreach ($this->args as $key => $value) { if ($key === 0) { $this->command = \trim($value); } elseif (\is_int($key)) { ...
[ "protected", "function", "findCommand", "(", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "args", "[", "0", "]", ")", ")", "{", "return", ";", "}", "$", "newArgs", "=", "[", "]", ";", "foreach", "(", "$", "this", "->"...
find command name. it is first argument.
[ "find", "command", "name", ".", "it", "is", "first", "argument", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L82-L101
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.getOpt
public function getOpt(string $name, $default = null) { // is long-opt if (isset($name{1})) { return $this->lOpt($name, $default); } return $this->sOpt($name, $default); }
php
public function getOpt(string $name, $default = null) { // is long-opt if (isset($name{1})) { return $this->lOpt($name, $default); } return $this->sOpt($name, $default); }
[ "public", "function", "getOpt", "(", "string", "$", "name", ",", "$", "default", "=", "null", ")", "{", "// is long-opt", "if", "(", "isset", "(", "$", "name", "{", "1", "}", ")", ")", "{", "return", "$", "this", "->", "lOpt", "(", "$", "name", "...
get (long/short)opt value eg: -e dev --name sam @param string $name @param null $default @return bool|mixed|null
[ "get", "(", "long", "/", "short", ")", "opt", "value", "eg", ":", "-", "e", "dev", "--", "name", "sam" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L273-L281
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.getBoolOpt
public function getBoolOpt(string $name, bool $default = false): bool { return (bool)$this->getOpt($name, $default); }
php
public function getBoolOpt(string $name, bool $default = false): bool { return (bool)$this->getOpt($name, $default); }
[ "public", "function", "getBoolOpt", "(", "string", "$", "name", ",", "bool", "$", "default", "=", "false", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "getOpt", "(", "$", "name", ",", "$", "default", ")", ";", "}" ]
get (long/short)opt value(bool) eg: -h --help @param string $name @param bool $default @return bool
[ "get", "(", "long", "/", "short", ")", "opt", "value", "(", "bool", ")", "eg", ":", "-", "h", "--", "help" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L316-L319
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.hasOpt
public function hasOpt(string $name): bool { return isset($this->sOpts[$name]) || isset($this->lOpts[$name]); }
php
public function hasOpt(string $name): bool { return isset($this->sOpts[$name]) || isset($this->lOpts[$name]); }
[ "public", "function", "hasOpt", "(", "string", "$", "name", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "sOpts", "[", "$", "name", "]", ")", "||", "isset", "(", "$", "this", "->", "lOpts", "[", "$", "name", "]", ")", ";", ...
check option exists @param $name @return bool
[ "check", "option", "exists" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L331-L334
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.sBoolOpt
public function sBoolOpt(string $name, $default = false): bool { $val = $this->sOpt($name); return \is_bool($val) ? $val : (bool)$default; }
php
public function sBoolOpt(string $name, $default = false): bool { $val = $this->sOpt($name); return \is_bool($val) ? $val : (bool)$default; }
[ "public", "function", "sBoolOpt", "(", "string", "$", "name", ",", "$", "default", "=", "false", ")", ":", "bool", "{", "$", "val", "=", "$", "this", "->", "sOpt", "(", "$", "name", ")", ";", "return", "\\", "is_bool", "(", "$", "val", ")", "?", ...
get short-opt value(bool) @param string $name @param bool $default @return bool
[ "get", "short", "-", "opt", "value", "(", "bool", ")" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L422-L427
inhere/php-console
src/IO/AbstractInput.php
AbstractInput.lBoolOpt
public function lBoolOpt(string $name, $default = false): bool { $val = $this->lOpt($name); return \is_bool($val) ? $val : (bool)$default; }
php
public function lBoolOpt(string $name, $default = false): bool { $val = $this->lOpt($name); return \is_bool($val) ? $val : (bool)$default; }
[ "public", "function", "lBoolOpt", "(", "string", "$", "name", ",", "$", "default", "=", "false", ")", ":", "bool", "{", "$", "val", "=", "$", "this", "->", "lOpt", "(", "$", "name", ")", ";", "return", "\\", "is_bool", "(", "$", "val", ")", "?", ...
get long-opt value(bool) @param string $name @param bool $default @return bool
[ "get", "long", "-", "opt", "value", "(", "bool", ")" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/AbstractInput.php#L510-L515
inhere/php-console
src/Console.php
Console.writef
public static function writef(string $format, ...$args): int { return self::write(\sprintf($format, ...$args)); }
php
public static function writef(string $format, ...$args): int { return self::write(\sprintf($format, ...$args)); }
[ "public", "static", "function", "writef", "(", "string", "$", "format", ",", "...", "$", "args", ")", ":", "int", "{", "return", "self", "::", "write", "(", "\\", "sprintf", "(", "$", "format", ",", "...", "$", "args", ")", ")", ";", "}" ]
Format and write message to terminal. like printf() @param string $format @param mixed ...$args @return int
[ "Format", "and", "write", "message", "to", "terminal", ".", "like", "printf", "()" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L102-L105
inhere/php-console
src/Console.php
Console.printf
public static function printf(string $format, ...$args): int { return self::write(\sprintf($format, ...$args)); }
php
public static function printf(string $format, ...$args): int { return self::write(\sprintf($format, ...$args)); }
[ "public", "static", "function", "printf", "(", "string", "$", "format", ",", "...", "$", "args", ")", ":", "int", "{", "return", "self", "::", "write", "(", "\\", "sprintf", "(", "$", "format", ",", "...", "$", "args", ")", ")", ";", "}" ]
Format and write message to terminal. like printf() @param string $format @param mixed ...$args @return int
[ "Format", "and", "write", "message", "to", "terminal", ".", "like", "printf", "()" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L113-L116
inhere/php-console
src/Console.php
Console.writeRaw
public static function writeRaw($message, $nl = true, $quit = false, array $opts = []): int { $opts['color'] = false; return self::write($message, $nl, $quit, $opts); }
php
public static function writeRaw($message, $nl = true, $quit = false, array $opts = []): int { $opts['color'] = false; return self::write($message, $nl, $quit, $opts); }
[ "public", "static", "function", "writeRaw", "(", "$", "message", ",", "$", "nl", "=", "true", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "$", "opts", "[", "'color'", "]", "=", "false", ";", "...
Write raw data to stdout, will disable color render. @param string|array $message @param bool $nl @param bool|int $quit @param array $opts @return int
[ "Write", "raw", "data", "to", "stdout", "will", "disable", "color", "render", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L126-L130
inhere/php-console
src/Console.php
Console.writeln
public static function writeln($message, $quit = false, array $opts = []): int { return self::write($message, true, $quit, $opts); }
php
public static function writeln($message, $quit = false, array $opts = []): int { return self::write($message, true, $quit, $opts); }
[ "public", "static", "function", "writeln", "(", "$", "message", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "return", "self", "::", "write", "(", "$", "message", ",", "true", ",", "$", "quit", "...
Write data to stdout with newline. @param string|array $message @param array $opts @param bool|int $quit @return int
[ "Write", "data", "to", "stdout", "with", "newline", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L139-L142
inhere/php-console
src/Console.php
Console.write
public static function write($messages, $nl = true, $quit = false, array $opts = []): int { if (\is_array($messages)) { $messages = \implode($nl ? \PHP_EOL : '', $messages); } $messages = (string)$messages; if (!isset($opts['color']) || $opts['color']) { $me...
php
public static function write($messages, $nl = true, $quit = false, array $opts = []): int { if (\is_array($messages)) { $messages = \implode($nl ? \PHP_EOL : '', $messages); } $messages = (string)$messages; if (!isset($opts['color']) || $opts['color']) { $me...
[ "public", "static", "function", "write", "(", "$", "messages", ",", "$", "nl", "=", "true", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "if", "(", "\\", "is_array", "(", "$", "messages", ")", ...
Write a message to standard output stream. @param string|array $messages Output message @param boolean $nl True 会添加换行符, False 原样输出,不添加换行符 @param int|boolean $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit. @param array $opts Some options f...
[ "Write", "a", "message", "to", "standard", "output", "stream", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L159-L201
inhere/php-console
src/Console.php
Console.stdout
public static function stdout($text, $nl = true, $quit = false): void { self::write($text, $nl, $quit); }
php
public static function stdout($text, $nl = true, $quit = false): void { self::write($text, $nl, $quit); }
[ "public", "static", "function", "stdout", "(", "$", "text", ",", "$", "nl", "=", "true", ",", "$", "quit", "=", "false", ")", ":", "void", "{", "self", "::", "write", "(", "$", "text", ",", "$", "nl", ",", "$", "quit", ")", ";", "}" ]
Logs data to stdout @param string|array $text @param bool $nl @param bool|int $quit
[ "Logs", "data", "to", "stdout" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L209-L212
inhere/php-console
src/Console.php
Console.stderr
public static function stderr($text, $nl = true, $quit = -200): void { self::write($text, $nl, $quit, [ 'stream' => \STDERR, ]); }
php
public static function stderr($text, $nl = true, $quit = -200): void { self::write($text, $nl, $quit, [ 'stream' => \STDERR, ]); }
[ "public", "static", "function", "stderr", "(", "$", "text", ",", "$", "nl", "=", "true", ",", "$", "quit", "=", "-", "200", ")", ":", "void", "{", "self", "::", "write", "(", "$", "text", ",", "$", "nl", ",", "$", "quit", ",", "[", "'stream'", ...
Logs data to stderr @param string|array $text @param bool $nl @param bool|int $quit
[ "Logs", "data", "to", "stderr" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L220-L225
inhere/php-console
src/Console.php
Console.log
public static function log(string $msg, array $data = [], int $level = self::VERB_DEBUG, array $opts = []): void { $levelName = self::LEVEL_NAMES[$level] ?? 'INFO'; $colorName = self::LEVEL2TAG[$level] ?? 'info'; $taggedName = ColorTag::add($levelName, $colorName); $userOpts = [];...
php
public static function log(string $msg, array $data = [], int $level = self::VERB_DEBUG, array $opts = []): void { $levelName = self::LEVEL_NAMES[$level] ?? 'INFO'; $colorName = self::LEVEL2TAG[$level] ?? 'info'; $taggedName = ColorTag::add($levelName, $colorName); $userOpts = [];...
[ "public", "static", "function", "log", "(", "string", "$", "msg", ",", "array", "$", "data", "=", "[", "]", ",", "int", "$", "level", "=", "self", "::", "VERB_DEBUG", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "void", "{", "$", "levelNam...
Print log message to console @param string $msg @param array $data @param int $level @param array $opts [ '_category' => 'application', 'process' => 'work', 'pid' => 234, 'coId' => 12, ]
[ "Print", "log", "message", "to", "console" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L256-L281
inhere/php-console
src/Console.php
Console.read
public static function read($message = null, bool $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, ], $opts); return \file_get_contents($op...
php
public static function read($message = null, bool $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, ], $opts); return \file_get_contents($op...
[ "public", "static", "function", "read", "(", "$", "message", "=", "null", ",", "bool", "$", "nl", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "string", "{", "if", "(", "$", "message", ")", "{", "self", "::", "write", "(", ...
Read message from STDIN @param mixed $message @param bool $nl @param array $opts @return string
[ "Read", "message", "from", "STDIN" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L295-L307
inhere/php-console
src/Console.php
Console.readln
public static function readln($message = null, $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, ], $opts); return \trim(\fgets($opts['strea...
php
public static function readln($message = null, $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, ], $opts); return \trim(\fgets($opts['strea...
[ "public", "static", "function", "readln", "(", "$", "message", "=", "null", ",", "$", "nl", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "string", "{", "if", "(", "$", "message", ")", "{", "self", "::", "write", "(", "$", "...
Gets line from file pointer @param mixed $message @param bool $nl @param array $opts [ 'stream' => \STDIN ] @return string
[ "Gets", "line", "from", "file", "pointer" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L320-L332
inhere/php-console
src/Console.php
Console.readRow
public static function readRow($message = null, $nl = false): string { return self::readln($message, $nl); }
php
public static function readRow($message = null, $nl = false): string { return self::readln($message, $nl); }
[ "public", "static", "function", "readRow", "(", "$", "message", "=", "null", ",", "$", "nl", "=", "false", ")", ":", "string", "{", "return", "self", "::", "readln", "(", "$", "message", ",", "$", "nl", ")", ";", "}" ]
Read input information @param mixed $message 若不为空,则先输出文本 @param bool $nl true 会添加换行符 false 原样输出,不添加换行符 @return string
[ "Read", "input", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L340-L343
inhere/php-console
src/Console.php
Console.readSafe
public static function readSafe($message = null, bool $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, 'allowTags' => null, ], $opts); ...
php
public static function readSafe($message = null, bool $nl = false, array $opts = []): string { if ($message) { self::write($message, $nl); } $opts = \array_merge([ 'length' => 1024, 'stream' => \STDIN, 'allowTags' => null, ], $opts); ...
[ "public", "static", "function", "readSafe", "(", "$", "message", "=", "null", ",", "bool", "$", "nl", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "string", "{", "if", "(", "$", "message", ")", "{", "self", "::", "write", "("...
Gets line from file pointer and strip HTML tags @param mixed $message @param bool $nl @param array $opts @return string
[ "Gets", "line", "from", "file", "pointer", "and", "strip", "HTML", "tags" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L353-L366
inhere/php-console
src/Console.php
Console.readChar
public static function readChar(string $message = '', bool $nl = false): string { $line = self::readln($message, $nl); return $line !== '' ? $line[0] : ''; }
php
public static function readChar(string $message = '', bool $nl = false): string { $line = self::readln($message, $nl); return $line !== '' ? $line[0] : ''; }
[ "public", "static", "function", "readChar", "(", "string", "$", "message", "=", "''", ",", "bool", "$", "nl", "=", "false", ")", ":", "string", "{", "$", "line", "=", "self", "::", "readln", "(", "$", "message", ",", "$", "nl", ")", ";", "return", ...
Gets first character from file pointer @param string $message @param bool $nl @return string
[ "Gets", "first", "character", "from", "file", "pointer" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L374-L379
inhere/php-console
src/Console.php
Console.readFirst
public static function readFirst(string $message = '', bool $nl = false): string { return self::readChar($message, $nl); }
php
public static function readFirst(string $message = '', bool $nl = false): string { return self::readChar($message, $nl); }
[ "public", "static", "function", "readFirst", "(", "string", "$", "message", "=", "''", ",", "bool", "$", "nl", "=", "false", ")", ":", "string", "{", "return", "self", "::", "readChar", "(", "$", "message", ",", "$", "nl", ")", ";", "}" ]
Read input first char @param string $message @param bool $nl @return string
[ "Read", "input", "first", "char" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L387-L390
inhere/php-console
src/Console.php
Console.stopBuffer
public static function stopBuffer($flush = true, $nl = false, $quit = false, array $opts = []): string { self::$buffering = false; if ($flush && self::$buffer) { // all text have been rendered by Style::render() in every write(); $opts['color'] = false; // flush...
php
public static function stopBuffer($flush = true, $nl = false, $quit = false, array $opts = []): string { self::$buffering = false; if ($flush && self::$buffer) { // all text have been rendered by Style::render() in every write(); $opts['color'] = false; // flush...
[ "public", "static", "function", "stopBuffer", "(", "$", "flush", "=", "true", ",", "$", "nl", "=", "false", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "string", "{", "self", "::", "$", "buffering", "=", "f...
Stop buffering @see write() @param bool $flush Whether flush buffer to output stream @param bool $nl Default is False, because the last write() have been added "\n" @param bool $quit @param array $opts @return string If flush = False, will return all buffer text.
[ "Stop", "buffering" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L445-L461
inhere/php-console
src/Console.php
Console.flushBuffer
public static function flushBuffer($nl = false, $quit = false, array $opts = []): void { self::stopBuffer(true, $nl, $quit, $opts); }
php
public static function flushBuffer($nl = false, $quit = false, array $opts = []): void { self::stopBuffer(true, $nl, $quit, $opts); }
[ "public", "static", "function", "flushBuffer", "(", "$", "nl", "=", "false", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "void", "{", "self", "::", "stopBuffer", "(", "true", ",", "$", "nl", ",", "$", "quit...
Stop buffering and flush buffer text @see write() @param bool $nl @param bool $quit @param array $opts
[ "Stop", "buffering", "and", "flush", "buffer", "text" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Console.php#L470-L473
inhere/php-console
examples/Controller/ProcessController.php
ProcessController.runScriptCommand
public function runScriptCommand(): void { /*$script = '<?php echo "foo"; ?>';*/ $script = '<?php print_r($_SERVER); ?>'; // $tmpDir = CliUtil::getTempDir(); // $tmpFile = $tmpDir . '/' . md5($script) . '.php'; // file_put_contents($tmpFile, $script); $descriptorSpe...
php
public function runScriptCommand(): void { /*$script = '<?php echo "foo"; ?>';*/ $script = '<?php print_r($_SERVER); ?>'; // $tmpDir = CliUtil::getTempDir(); // $tmpFile = $tmpDir . '/' . md5($script) . '.php'; // file_put_contents($tmpFile, $script); $descriptorSpe...
[ "public", "function", "runScriptCommand", "(", ")", ":", "void", "{", "/*$script = '<?php echo \"foo\"; ?>';*/", "$", "script", "=", "'<?php print_r($_SERVER); ?>'", ";", "// $tmpDir = CliUtil::getTempDir();", "// $tmpFile = $tmpDir . '/' . md5($script) . '.php';", "// file_put_conte...
simple process example for child-process
[ "simple", "process", "example", "for", "child", "-", "process" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ProcessController.php#L39-L77
inhere/php-console
examples/Controller/ProcessController.php
ProcessController.childProcessCommand
public function childProcessCommand(): void { $ret = ProcessUtil::create(function ($pid) { echo "print in process $pid"; sleep(5); }); if ($ret === false) { $this->output->liteError('current env is not support process create.'); } }
php
public function childProcessCommand(): void { $ret = ProcessUtil::create(function ($pid) { echo "print in process $pid"; sleep(5); }); if ($ret === false) { $this->output->liteError('current env is not support process create.'); } }
[ "public", "function", "childProcessCommand", "(", ")", ":", "void", "{", "$", "ret", "=", "ProcessUtil", "::", "create", "(", "function", "(", "$", "pid", ")", "{", "echo", "\"print in process $pid\"", ";", "sleep", "(", "5", ")", ";", "}", ")", ";", "...
simple process example for child-process
[ "simple", "process", "example", "for", "child", "-", "process" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ProcessController.php#L82-L93
inhere/php-console
examples/Controller/ProcessController.php
ProcessController.daemonRunCommand
public function daemonRunCommand(): void { $ret = ProcessUtil::daemonRun(function ($pid){ $this->output->info("will running background by new process: $pid"); }); if ($ret === 0) { $this->output->liteError('current env is not support process create.'); } ...
php
public function daemonRunCommand(): void { $ret = ProcessUtil::daemonRun(function ($pid){ $this->output->info("will running background by new process: $pid"); }); if ($ret === 0) { $this->output->liteError('current env is not support process create.'); } ...
[ "public", "function", "daemonRunCommand", "(", ")", ":", "void", "{", "$", "ret", "=", "ProcessUtil", "::", "daemonRun", "(", "function", "(", "$", "pid", ")", "{", "$", "this", "->", "output", "->", "info", "(", "\"will running background by new process: $pid...
simple process example for daemon run @throws \RuntimeException
[ "simple", "process", "example", "for", "daemon", "run" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ProcessController.php#L99-L108
inhere/php-console
examples/Controller/ProcessController.php
ProcessController.runInBackgroundCommand
public function runInBackgroundCommand(): void { $script = '<?php print_r($_SERVER); ?>'; $ret = Sys::execInBackground("php $script"); if ($ret === false) { $this->output->liteError('current env is not support process create.'); } }
php
public function runInBackgroundCommand(): void { $script = '<?php print_r($_SERVER); ?>'; $ret = Sys::execInBackground("php $script"); if ($ret === false) { $this->output->liteError('current env is not support process create.'); } }
[ "public", "function", "runInBackgroundCommand", "(", ")", ":", "void", "{", "$", "script", "=", "'<?php print_r($_SERVER); ?>'", ";", "$", "ret", "=", "Sys", "::", "execInBackground", "(", "\"php $script\"", ")", ";", "if", "(", "$", "ret", "===", "false", "...
simple process example for run In Background
[ "simple", "process", "example", "for", "run", "In", "Background" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Controller/ProcessController.php#L113-L121
inhere/php-console
src/Util/Show.php
Show.prettyJSON
public static function prettyJSON( $data, int $flags = \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES ): int { $string = (string)\json_encode($data, $flags); return Console::write($string); }
php
public static function prettyJSON( $data, int $flags = \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES ): int { $string = (string)\json_encode($data, $flags); return Console::write($string); }
[ "public", "static", "function", "prettyJSON", "(", "$", "data", ",", "int", "$", "flags", "=", "\\", "JSON_PRETTY_PRINT", "|", "\\", "JSON_UNESCAPED_UNICODE", "|", "\\", "JSON_UNESCAPED_SLASHES", ")", ":", "int", "{", "$", "string", "=", "(", "string", ")", ...
Print JSON @param mixed $data @param int $flags @return int
[ "Print", "JSON" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L187-L194
inhere/php-console
src/Util/Show.php
Show.padding
public static function padding(array $data, string $title = '', array $opts = []): void { Padding::show($data, $title, $opts); }
php
public static function padding(array $data, string $title = '', array $opts = []): void { Padding::show($data, $title, $opts); }
[ "public", "static", "function", "padding", "(", "array", "$", "data", ",", "string", "$", "title", "=", "''", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "void", "{", "Padding", "::", "show", "(", "$", "data", ",", "$", "title", ",", "$",...
```php $data = [ 'Eggs' => '$1.99', 'Oatmeal' => '$4.99', 'Bacon' => '$2.99', ]; ``` @param array $data @param string $title @param array $opts
[ "php", "$data", "=", "[", "Eggs", "=", ">", "$1", ".", "99", "Oatmeal", "=", ">", "$4", ".", "99", "Bacon", "=", ">", "$2", ".", "99", "]", ";" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L250-L253
inhere/php-console
src/Util/Show.php
Show.aList
public static function aList($data, string $title = '', array $opts = []) { return SingleList::show($data, $title, $opts); }
php
public static function aList($data, string $title = '', array $opts = []) { return SingleList::show($data, $title, $opts); }
[ "public", "static", "function", "aList", "(", "$", "data", ",", "string", "$", "title", "=", "''", ",", "array", "$", "opts", "=", "[", "]", ")", "{", "return", "SingleList", "::", "show", "(", "$", "data", ",", "$", "title", ",", "$", "opts", ")...
Show a single list ``` $title = 'list title'; $data = [ 'name' => 'value text', 'name2' => 'value text 2', ]; ``` @param array $data @param string $title @param array $opts More {@see FormatUtil::spliceKeyValue()} @return int|string
[ "Show", "a", "single", "list" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L271-L274
inhere/php-console
src/Util/Show.php
Show.panel
public static function panel($data, string $title = 'Information Panel', array $opts = []): int { return Panel::show($data, $title, $opts); }
php
public static function panel($data, string $title = 'Information Panel', array $opts = []): int { return Panel::show($data, $title, $opts); }
[ "public", "static", "function", "panel", "(", "$", "data", ",", "string", "$", "title", "=", "'Information Panel'", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "return", "Panel", "::", "show", "(", "$", "data", ",", "$", "title", ...
Show information data panel @param mixed $data @param string $title @param array $opts @return int
[ "Show", "information", "data", "panel" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L337-L340
inhere/php-console
src/Util/Show.php
Show.table
public static function table(array $data, string $title = 'Data Table', array $opts = []): int { return Table::show($data, $title, $opts); }
php
public static function table(array $data, string $title = 'Data Table', array $opts = []): int { return Table::show($data, $title, $opts); }
[ "public", "static", "function", "table", "(", "array", "$", "data", ",", "string", "$", "title", "=", "'Data Table'", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "return", "Table", "::", "show", "(", "$", "data", ",", "$", "titl...
Tabular data display @param array $data @param string $title @param array $opts @return int @see Table::show()
[ "Tabular", "data", "display" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L363-L366
inhere/php-console
src/Util/Show.php
Show.spinner
public static function spinner(string $msg = '', $ended = false): void { static $chars = '-\|/'; static $counter = 0; static $lastTime = null; $tpl = (Cli::isSupportColor() ? "\x0D\x1B[2K" : "\x0D\r") . '%s'; if ($ended) { printf($tpl, $msg); return;...
php
public static function spinner(string $msg = '', $ended = false): void { static $chars = '-\|/'; static $counter = 0; static $lastTime = null; $tpl = (Cli::isSupportColor() ? "\x0D\x1B[2K" : "\x0D\r") . '%s'; if ($ended) { printf($tpl, $msg); return;...
[ "public", "static", "function", "spinner", "(", "string", "$", "msg", "=", "''", ",", "$", "ended", "=", "false", ")", ":", "void", "{", "static", "$", "chars", "=", "'-\\|/'", ";", "static", "$", "counter", "=", "0", ";", "static", "$", "lastTime", ...
show a spinner icon message ```php $total = 5000; while ($total--) { Show::spinner(); usleep(100); } Show::spinner('Done', true); ``` @param string $msg @param bool $ended
[ "show", "a", "spinner", "icon", "message", "php", "$total", "=", "5000", ";", "while", "(", "$total", "--", ")", "{", "Show", "::", "spinner", "()", ";", "usleep", "(", "100", ")", ";", "}", "Show", "::", "spinner", "(", "Done", "true", ")", ";" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L385-L410
inhere/php-console
src/Util/Show.php
Show.loading
public static function loading(string $msg = 'Loading ', $ended = false): void { self::pending($msg, $ended); }
php
public static function loading(string $msg = 'Loading ', $ended = false): void { self::pending($msg, $ended); }
[ "public", "static", "function", "loading", "(", "string", "$", "msg", "=", "'Loading '", ",", "$", "ended", "=", "false", ")", ":", "void", "{", "self", "::", "pending", "(", "$", "msg", ",", "$", "ended", ")", ";", "}" ]
alias of the pending() @param string $msg @param bool $ended
[ "alias", "of", "the", "pending", "()" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L417-L420
inhere/php-console
src/Util/Show.php
Show.pointing
public static function pointing(string $msg = 'handling ', $ended = false) { static $counter = 0; if ($ended) { return Console::writef(' (%s %d)', $msg ?: 'Total', $counter); } if ($counter === 0 && $msg) { echo $msg; } $counter++; ...
php
public static function pointing(string $msg = 'handling ', $ended = false) { static $counter = 0; if ($ended) { return Console::writef(' (%s %d)', $msg ?: 'Total', $counter); } if ($counter === 0 && $msg) { echo $msg; } $counter++; ...
[ "public", "static", "function", "pointing", "(", "string", "$", "msg", "=", "'handling '", ",", "$", "ended", "=", "false", ")", "{", "static", "$", "counter", "=", "0", ";", "if", "(", "$", "ended", ")", "{", "return", "Console", "::", "writef", "("...
show a pending message ```php $total = 8000; while ($total--) { Show::pointing(); usleep(200); } Show::pointing('Total', true); ``` @param string $msg @param bool $ended @return int|mixed
[ "show", "a", "pending", "message", "php", "$total", "=", "8000", ";", "while", "(", "$total", "--", ")", "{", "Show", "::", "pointing", "()", ";", "usleep", "(", "200", ")", ";", "}", "Show", "::", "pointing", "(", "Total", "true", ")", ";" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L475-L490
inhere/php-console
src/Util/Show.php
Show.progressTxt
public static function progressTxt(int $total, string $msg, string $doneMsg = ''): \Generator { return SimpleTextBar::gen($total, $msg, $doneMsg); }
php
public static function progressTxt(int $total, string $msg, string $doneMsg = ''): \Generator { return SimpleTextBar::gen($total, $msg, $doneMsg); }
[ "public", "static", "function", "progressTxt", "(", "int", "$", "total", ",", "string", "$", "msg", ",", "string", "$", "doneMsg", "=", "''", ")", ":", "\\", "Generator", "{", "return", "SimpleTextBar", "::", "gen", "(", "$", "total", ",", "$", "msg", ...
Render a simple text progress bar by 'yield' @param int $total @param string $msg @param string $doneMsg @return \Generator
[ "Render", "a", "simple", "text", "progress", "bar", "by", "yield" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L531-L534
inhere/php-console
src/Util/Show.php
Show.createProgressBar
public static function createProgressBar($max = 0, $start = true): ProgressBar { $bar = new ProgressBar(null, $max); if ($start) { $bar->start(); } return $bar; }
php
public static function createProgressBar($max = 0, $start = true): ProgressBar { $bar = new ProgressBar(null, $max); if ($start) { $bar->start(); } return $bar; }
[ "public", "static", "function", "createProgressBar", "(", "$", "max", "=", "0", ",", "$", "start", "=", "true", ")", ":", "ProgressBar", "{", "$", "bar", "=", "new", "ProgressBar", "(", "null", ",", "$", "max", ")", ";", "if", "(", "$", "start", ")...
create ProgressBar ```php $max = 200; $bar = Show::createProgressBar($max); while ($i <= $total) { $bar->advance(); usleep(50000); $i++; } $bar->finish(); ``` @param int $max @param bool $start @return ProgressBar @throws \LogicException
[ "create", "ProgressBar", "php", "$max", "=", "200", ";", "$bar", "=", "Show", "::", "createProgressBar", "(", "$max", ")", ";", "while", "(", "$i", "<", "=", "$total", ")", "{", "$bar", "-", ">", "advance", "()", ";", "usleep", "(", "50000", ")", "...
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L565-L574
inhere/php-console
src/Util/Show.php
Show.write
public static function write($messages, $nl = true, $quit = false, array $opts = []): int { return Console::write($messages, $nl, $quit, $opts); }
php
public static function write($messages, $nl = true, $quit = false, array $opts = []): int { return Console::write($messages, $nl, $quit, $opts); }
[ "public", "static", "function", "write", "(", "$", "messages", ",", "$", "nl", "=", "true", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "return", "Console", "::", "write", "(", "$", "messages", ...
Write a message to standard output stream. @param string|array $messages Output message @param boolean $nl True 会添加换行符, False 原样输出,不添加换行符 @param int|boolean $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit. @param array $opts Some options fo...
[ "Write", "a", "message", "to", "standard", "output", "stream", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L695-L698
inhere/php-console
src/Util/Show.php
Show.writeRaw
public static function writeRaw($message, bool $nl = true, $quit = false, array $opts = []): int { $opts['color'] = false; return Console::write($message, $nl, $quit, $opts); }
php
public static function writeRaw($message, bool $nl = true, $quit = false, array $opts = []): int { $opts['color'] = false; return Console::write($message, $nl, $quit, $opts); }
[ "public", "static", "function", "writeRaw", "(", "$", "message", ",", "bool", "$", "nl", "=", "true", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "int", "{", "$", "opts", "[", "'color'", "]", "=", "false", ...
Write raw data to stdout, will disable color render. @param string|array $message @param bool $nl @param bool|int $quit @param array $opts @return int
[ "Write", "raw", "data", "to", "stdout", "will", "disable", "color", "render", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Show.php#L708-L712
inhere/php-console
src/Controller.php
Controller.configure
protected function configure(): void { // eg. IndexConfigure() for indexCommand() $method = $this->action . 'Configure'; if (\method_exists($this, $method)) { $this->$method(); } }
php
protected function configure(): void { // eg. IndexConfigure() for indexCommand() $method = $this->action . 'Configure'; if (\method_exists($this, $method)) { $this->$method(); } }
[ "protected", "function", "configure", "(", ")", ":", "void", "{", "// eg. IndexConfigure() for indexCommand()", "$", "method", "=", "$", "this", "->", "action", ".", "'Configure'", ";", "if", "(", "\\", "method_exists", "(", "$", "this", ",", "$", "method", ...
Load command configure
[ "Load", "command", "configure" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Controller.php#L130-L138
inhere/php-console
src/Controller.php
Controller.execute
final public function execute($input, $output) { $action = $this->action; $group = static::getName(); if ($this->isDisabled($action)) { $output->liteError(\sprintf("Sorry, The command '%s' is invalid in the group '%s'!", $action, $group)); return -1; } ...
php
final public function execute($input, $output) { $action = $this->action; $group = static::getName(); if ($this->isDisabled($action)) { $output->liteError(\sprintf("Sorry, The command '%s' is invalid in the group '%s'!", $action, $group)); return -1; } ...
[ "final", "public", "function", "execute", "(", "$", "input", ",", "$", "output", ")", "{", "$", "action", "=", "$", "this", "->", "action", ";", "$", "group", "=", "static", "::", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "isDisabled"...
Run command action in the group @param Input $input @param Output $output @return mixed @throws \ReflectionException
[ "Run", "command", "action", "in", "the", "group" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Controller.php#L148-L196
inhere/php-console
src/Controller.php
Controller.helpCommand
final public function helpCommand(): int { $action = $this->action; // For all sub-commands of the controller if (!$action && !($action = $this->getFirstArg())) { $this->showCommandList(); return 0; } $action = Str::camelCase($action); $meth...
php
final public function helpCommand(): int { $action = $this->action; // For all sub-commands of the controller if (!$action && !($action = $this->getFirstArg())) { $this->showCommandList(); return 0; } $action = Str::camelCase($action); $meth...
[ "final", "public", "function", "helpCommand", "(", ")", ":", "int", "{", "$", "action", "=", "$", "this", "->", "action", ";", "// For all sub-commands of the controller", "if", "(", "!", "$", "action", "&&", "!", "(", "$", "action", "=", "$", "this", "-...
Show help of the controller command group or specified command action @usage <info>{name}:[command] -h</info> OR <info>{command} [command]</info> OR <info>{name} [command] -h</info> @options -s, --search Search command by input keywords --format Set the help information dump format(raw, xml, json, markdown) @exam...
[ "Show", "help", "of", "the", "controller", "command", "group", "or", "specified", "command", "action", "@usage", "<info", ">", "{", "name", "}", ":", "[", "command", "]", "-", "h<", "/", "info", ">", "OR", "<info", ">", "{", "command", "}", "[", "com...
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Controller.php#L241-L257
inhere/php-console
src/Controller.php
Controller.showCommandList
final public function showCommandList(): void { $this->beforeShowCommandList(); $ref = new \ReflectionClass($this); $sName = \lcfirst(self::getName() ?: $ref->getShortName()); if (!($classDes = self::getDescription())) { $classDes = PhpDoc::description($ref->getDocCom...
php
final public function showCommandList(): void { $this->beforeShowCommandList(); $ref = new \ReflectionClass($this); $sName = \lcfirst(self::getName() ?: $ref->getShortName()); if (!($classDes = self::getDescription())) { $classDes = PhpDoc::description($ref->getDocCom...
[ "final", "public", "function", "showCommandList", "(", ")", ":", "void", "{", "$", "this", "->", "beforeShowCommandList", "(", ")", ";", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "sName", "=", "\\", "lcfirst", "(...
Display all sub-commands list of the controller class @throws \ReflectionException
[ "Display", "all", "sub", "-", "commands", "list", "of", "the", "controller", "class" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Controller.php#L268-L347
inhere/php-console
src/Traits/ApplicationHelpTrait.php
ApplicationHelpTrait.showVersionInfo
public function showVersionInfo(): void { $os = \PHP_OS; $date = \date('Y.m.d'); $logo = ''; $name = $this->getParam('name', 'Console Application'); $version = $this->getParam('version', 'Unknown'); $publishAt = $this->getParam('publishAt...
php
public function showVersionInfo(): void { $os = \PHP_OS; $date = \date('Y.m.d'); $logo = ''; $name = $this->getParam('name', 'Console Application'); $version = $this->getParam('version', 'Unknown'); $publishAt = $this->getParam('publishAt...
[ "public", "function", "showVersionInfo", "(", ")", ":", "void", "{", "$", "os", "=", "\\", "PHP_OS", ";", "$", "date", "=", "\\", "date", "(", "'Y.m.d'", ")", ";", "$", "logo", "=", "''", ";", "$", "name", "=", "$", "this", "->", "getParam", "(",...
Display the application version information
[ "Display", "the", "application", "version", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Traits/ApplicationHelpTrait.php#L32-L57
inhere/php-console
src/Traits/ApplicationHelpTrait.php
ApplicationHelpTrait.showHelpInfo
public function showHelpInfo(string $command = ''): void { /** @var \Inhere\Console\IO\Input $in */ $in = $this->input; // display help for a special command if ($command) { $in->setCommand($command); $in->setSOpt('h', true); $in->clearArgs(); ...
php
public function showHelpInfo(string $command = ''): void { /** @var \Inhere\Console\IO\Input $in */ $in = $this->input; // display help for a special command if ($command) { $in->setCommand($command); $in->setSOpt('h', true); $in->clearArgs(); ...
[ "public", "function", "showHelpInfo", "(", "string", "$", "command", "=", "''", ")", ":", "void", "{", "/** @var \\Inhere\\Console\\IO\\Input $in */", "$", "in", "=", "$", "this", "->", "input", ";", "// display help for a special command", "if", "(", "$", "comman...
Display the application help information @param string $command
[ "Display", "the", "application", "help", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Traits/ApplicationHelpTrait.php#L63-L92
inhere/php-console
src/Traits/ApplicationHelpTrait.php
ApplicationHelpTrait.showCommandList
public function showCommandList(): void { /** @var \Inhere\Console\IO\Input $input */ $input = $this->input; // has option: --auto-completion $autoComp = $input->getBoolOpt('auto-completion'); // has option: --shell-env $shellEnv = (string)$input->getLongOpt('shell-en...
php
public function showCommandList(): void { /** @var \Inhere\Console\IO\Input $input */ $input = $this->input; // has option: --auto-completion $autoComp = $input->getBoolOpt('auto-completion'); // has option: --shell-env $shellEnv = (string)$input->getLongOpt('shell-en...
[ "public", "function", "showCommandList", "(", ")", ":", "void", "{", "/** @var \\Inhere\\Console\\IO\\Input $input */", "$", "input", "=", "$", "this", "->", "input", ";", "// has option: --auto-completion", "$", "autoComp", "=", "$", "input", "->", "getBoolOpt", "(...
Display the application group/command list information
[ "Display", "the", "application", "group", "/", "command", "list", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Traits/ApplicationHelpTrait.php#L97-L217
inhere/php-console
src/Traits/ApplicationHelpTrait.php
ApplicationHelpTrait.dumpAutoCompletion
protected function dumpAutoCompletion(string $shellEnv, array $data): void { /** @var \Inhere\Console\IO\Input $input */ $input = $this->input; /** @var \Inhere\Console\IO\Output $output */ $output = $this->output; /** @var Router $router */ $router = $this->getRouter...
php
protected function dumpAutoCompletion(string $shellEnv, array $data): void { /** @var \Inhere\Console\IO\Input $input */ $input = $this->input; /** @var \Inhere\Console\IO\Output $output */ $output = $this->output; /** @var Router $router */ $router = $this->getRouter...
[ "protected", "function", "dumpAutoCompletion", "(", "string", "$", "shellEnv", ",", "array", "$", "data", ")", ":", "void", "{", "/** @var \\Inhere\\Console\\IO\\Input $input */", "$", "input", "=", "$", "this", "->", "input", ";", "/** @var \\Inhere\\Console\\IO\\Out...
zsh: php examples/app --auto-completion --shell-env zsh php examples/app --auto-completion --shell-env zsh --gen-file php examples/app --auto-completion --shell-env zsh --gen-file stdout bash: php examples/app --auto-completion --shell-env bash php examples/app --auto-completion --shell-env bash --gen-file php example...
[ "zsh", ":", "php", "examples", "/", "app", "--", "auto", "-", "completion", "--", "shell", "-", "env", "zsh", "php", "examples", "/", "app", "--", "auto", "-", "completion", "--", "shell", "-", "env", "zsh", "--", "gen", "-", "file", "php", "examples...
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Traits/ApplicationHelpTrait.php#L231-L301
inhere/php-console
src/Util/Helper.php
Helper.findSimilar
public static function findSimilar(string $need, $iterator, int $similarPercent = 45): array { if (!$need) { return []; } // find similar command names by similar_text() $similar = []; foreach ($iterator as $name) { \similar_text($need, $name, $perce...
php
public static function findSimilar(string $need, $iterator, int $similarPercent = 45): array { if (!$need) { return []; } // find similar command names by similar_text() $similar = []; foreach ($iterator as $name) { \similar_text($need, $name, $perce...
[ "public", "static", "function", "findSimilar", "(", "string", "$", "need", ",", "$", "iterator", ",", "int", "$", "similarPercent", "=", "45", ")", ":", "array", "{", "if", "(", "!", "$", "need", ")", "{", "return", "[", "]", ";", "}", "// find simil...
find similar text from an array|Iterator @param string $need @param \Iterator|array $iterator @param int $similarPercent @return array
[ "find", "similar", "text", "from", "an", "array|Iterator" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Helper.php#L103-L121
inhere/php-console
src/Util/Helper.php
Helper.getKeyMaxWidth
public static function getKeyMaxWidth(array $data, bool $expectInt = false): int { $keyMaxWidth = 0; foreach ($data as $key => $value) { // key is not a integer if (!$expectInt || !\is_numeric($key)) { $width = \mb_strlen($key, 'UTF-8'); $keyM...
php
public static function getKeyMaxWidth(array $data, bool $expectInt = false): int { $keyMaxWidth = 0; foreach ($data as $key => $value) { // key is not a integer if (!$expectInt || !\is_numeric($key)) { $width = \mb_strlen($key, 'UTF-8'); $keyM...
[ "public", "static", "function", "getKeyMaxWidth", "(", "array", "$", "data", ",", "bool", "$", "expectInt", "=", "false", ")", ":", "int", "{", "$", "keyMaxWidth", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")",...
get key Max Width @param array $data [ 'key1' => 'value1', 'key2-test' => 'value2', ] @param bool $expectInt @return int
[ "get", "key", "Max", "Width" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Util/Helper.php#L133-L146
inhere/php-console
src/Router.php
Router.addGroup
public function addGroup(string $name, $class = null, array $options = []): RouterInterface { /** * @var Controller $class name is an controller class */ if (!$class && \class_exists($name)) { $class = $name; $name = $class::getName(); } if...
php
public function addGroup(string $name, $class = null, array $options = []): RouterInterface { /** * @var Controller $class name is an controller class */ if (!$class && \class_exists($name)) { $class = $name; $name = $class::getName(); } if...
[ "public", "function", "addGroup", "(", "string", "$", "name", ",", "$", "class", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", ":", "RouterInterface", "{", "/**\n * @var Controller $class name is an controller class\n */", "if", "(",...
Register a app group command(by controller) @param string $name The controller name @param string|ControllerInterface $class The controller class @param array $options array: - aliases The command aliases - description The description message @return Router @throws \InvalidA...
[ "Register", "a", "app", "group", "command", "(", "by", "controller", ")" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Router.php#L69-L121
inhere/php-console
src/Router.php
Router.addCommand
public function addCommand(string $name, $handler = null, array $options = []): RouterInterface { /** * @var Command $name name is an command class */ if (!$handler && \class_exists($name)) { $handler = $name; $name = $name::getName(); } ...
php
public function addCommand(string $name, $handler = null, array $options = []): RouterInterface { /** * @var Command $name name is an command class */ if (!$handler && \class_exists($name)) { $handler = $name; $name = $name::getName(); } ...
[ "public", "function", "addCommand", "(", "string", "$", "name", ",", "$", "handler", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", ":", "RouterInterface", "{", "/**\n * @var Command $name name is an command class\n */", "if", "(", ...
Register a app independent console command @param string|CommandInterface $name @param string|\Closure|CommandInterface $handler @param array $options array: - aliases The command aliases - description The description message @return Router|RouterInterface @throws \InvalidArgumen...
[ "Register", "a", "app", "independent", "console", "command" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Router.php#L134-L195
inhere/php-console
src/Component/Interact/Choose.php
Choose.one
public static function one(string $description, $options, $default = null, bool $allowExit = true): string { if (!$description = \trim($description)) { Show::error('Please provide a description text!', 1); } $options = \is_array($options) ? $options : \explode(',', $options); ...
php
public static function one(string $description, $options, $default = null, bool $allowExit = true): string { if (!$description = \trim($description)) { Show::error('Please provide a description text!', 1); } $options = \is_array($options) ? $options : \explode(',', $options); ...
[ "public", "static", "function", "one", "(", "string", "$", "description", ",", "$", "options", ",", "$", "default", "=", "null", ",", "bool", "$", "allowExit", "=", "true", ")", ":", "string", "{", "if", "(", "!", "$", "description", "=", "\\", "trim...
Choose one of several options @param string $description @param string|array $options Option data e.g [ // option => value '1' => 'chengdu', '2' => 'beijing' ] @param string|int $default Default option @param bool $allowExit @return string
[ "Choose", "one", "of", "several", "options" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Interact/Choose.php#L29-L68
inhere/php-console
src/AbstractHandler.php
AbstractHandler.annotationVars
protected function annotationVars(): array { // e.g: `more info see {name}:index` return [ 'name' => self::getName(), 'group' => self::getName(), 'workDir' => $this->input->getPwd(), 'script' => $this->input->getScript(), // bin/a...
php
protected function annotationVars(): array { // e.g: `more info see {name}:index` return [ 'name' => self::getName(), 'group' => self::getName(), 'workDir' => $this->input->getPwd(), 'script' => $this->input->getScript(), // bin/a...
[ "protected", "function", "annotationVars", "(", ")", ":", "array", "{", "// e.g: `more info see {name}:index`", "return", "[", "'name'", "=>", "self", "::", "getName", "(", ")", ",", "'group'", "=>", "self", "::", "getName", "(", ")", ",", "'workDir'", "=>", ...
Provides parsable substitution variables for command annotations. Can be used in comments in commands 为命令注解提供可解析的替换变量. 可以在命令的注释中使用 you can append by: ```php protected function annotationVars(): array { return \array_merge(parent::annotationVars(), [ 'myVar' => 'value', ]); } ``` @return array
[ "Provides", "parsable", "substitution", "variables", "for", "command", "annotations", ".", "Can", "be", "used", "in", "comments", "in", "commands", "为命令注解提供可解析的替换变量", ".", "可以在命令的注释中使用" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L157-L169
inhere/php-console
src/AbstractHandler.php
AbstractHandler.run
public function run(string $command = '') { // load input definition configure $this->configure(); if ($this->input->sameOpt(['h', 'help'])) { $this->showHelp(); return 0; } // some prepare check if (true !== $this->prepare()) { r...
php
public function run(string $command = '') { // load input definition configure $this->configure(); if ($this->input->sameOpt(['h', 'help'])) { $this->showHelp(); return 0; } // some prepare check if (true !== $this->prepare()) { r...
[ "public", "function", "run", "(", "string", "$", "command", "=", "''", ")", "{", "// load input definition configure", "$", "this", "->", "configure", "(", ")", ";", "if", "(", "$", "this", "->", "input", "->", "sameOpt", "(", "[", "'h'", ",", "'help'", ...
run command @param string $command @return int|mixed @throws \RuntimeException @throws \InvalidArgumentException
[ "run", "command" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L182-L212
inhere/php-console
src/AbstractHandler.php
AbstractHandler.coroutineRun
public function coroutineRun(): bool { // $ch = new Coroutine\Channel(1); $ok = Coroutine::create(function () { $this->execute($this->input, $this->output); // $ch->push($result); }); // create co fail: if ((int)$ok === 0) { // if open deb...
php
public function coroutineRun(): bool { // $ch = new Coroutine\Channel(1); $ok = Coroutine::create(function () { $this->execute($this->input, $this->output); // $ch->push($result); }); // create co fail: if ((int)$ok === 0) { // if open deb...
[ "public", "function", "coroutineRun", "(", ")", ":", "bool", "{", "// $ch = new Coroutine\\Channel(1);", "$", "ok", "=", "Coroutine", "::", "create", "(", "function", "(", ")", "{", "$", "this", "->", "execute", "(", "$", "this", "->", "input", ",", "$", ...
coroutine run by swoole go() @return bool
[ "coroutine", "run", "by", "swoole", "go", "()" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L218-L242
inhere/php-console
src/AbstractHandler.php
AbstractHandler.prepare
protected function prepare(): bool { if ($this->processTitle && 'Darwin' !== \PHP_OS) { if (\function_exists('cli_set_process_title')) { \cli_set_process_title($this->processTitle); } elseif (\function_exists('setproctitle')) { \setproctitle($this->pro...
php
protected function prepare(): bool { if ($this->processTitle && 'Darwin' !== \PHP_OS) { if (\function_exists('cli_set_process_title')) { \cli_set_process_title($this->processTitle); } elseif (\function_exists('setproctitle')) { \setproctitle($this->pro...
[ "protected", "function", "prepare", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "processTitle", "&&", "'Darwin'", "!==", "\\", "PHP_OS", ")", "{", "if", "(", "\\", "function_exists", "(", "'cli_set_process_title'", ")", ")", "{", "\\", "cli...
prepare run @throws \InvalidArgumentException @throws \RuntimeException
[ "prepare", "run" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L273-L288
inhere/php-console
src/AbstractHandler.php
AbstractHandler.validateInput
public function validateInput(): bool { if (!$def = $this->definition) { return true; } $in = $this->input; $out = $this->output; $givenArgs = $errArgs = []; foreach ($in->getArgs() as $key => $value) { if (\is_int($key)) { ...
php
public function validateInput(): bool { if (!$def = $this->definition) { return true; } $in = $this->input; $out = $this->output; $givenArgs = $errArgs = []; foreach ($in->getArgs() as $key => $value) { if (\is_int($key)) { ...
[ "public", "function", "validateInput", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "def", "=", "$", "this", "->", "definition", ")", "{", "return", "true", ";", "}", "$", "in", "=", "$", "this", "->", "input", ";", "$", "out", "=", "$", "t...
validate input arguments and options @return bool @throws \InvalidArgumentException
[ "validate", "input", "arguments", "and", "options" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L295-L377
inhere/php-console
src/AbstractHandler.php
AbstractHandler.parseCommentsVars
protected function parseCommentsVars(string $str): string { // not use vars if (false === \strpos($str, self::HELP_VAR_LEFT)) { return $str; } static $map; if ($map === null) { foreach ($this->commentsVars as $key => $value) { $key = ...
php
protected function parseCommentsVars(string $str): string { // not use vars if (false === \strpos($str, self::HELP_VAR_LEFT)) { return $str; } static $map; if ($map === null) { foreach ($this->commentsVars as $key => $value) { $key = ...
[ "protected", "function", "parseCommentsVars", "(", "string", "$", "str", ")", ":", "string", "{", "// not use vars", "if", "(", "false", "===", "\\", "strpos", "(", "$", "str", ",", "self", "::", "HELP_VAR_LEFT", ")", ")", "{", "return", "$", "str", ";",...
替换注解中的变量为对应的值 @param string $str @return string
[ "替换注解中的变量为对应的值" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L418-L436
inhere/php-console
src/AbstractHandler.php
AbstractHandler.showHelp
protected function showHelp(): bool { if (!$definition = $this->getDefinition()) { return false; } // if has InputDefinition object. (The comment of the command will not be parsed and used at this time.) $help = $definition->getSynopsis(); // build usage ...
php
protected function showHelp(): bool { if (!$definition = $this->getDefinition()) { return false; } // if has InputDefinition object. (The comment of the command will not be parsed and used at this time.) $help = $definition->getSynopsis(); // build usage ...
[ "protected", "function", "showHelp", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "definition", "=", "$", "this", "->", "getDefinition", "(", ")", ")", "{", "return", "false", ";", "}", "// if has InputDefinition object. (The comment of the command will not be...
Display help information @return bool
[ "Display", "help", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L454-L486
inhere/php-console
src/AbstractHandler.php
AbstractHandler.showHelpByMethodAnnotations
protected function showHelpByMethodAnnotations(string $method, string $action = '', array $aliases = []): int { $ref = new \ReflectionClass($this); $name = $this->input->getCommand(); $this->logf( Console::VERB_CRAZY, 'display help info for the method=%s, action=%s,...
php
protected function showHelpByMethodAnnotations(string $method, string $action = '', array $aliases = []): int { $ref = new \ReflectionClass($this); $name = $this->input->getCommand(); $this->logf( Console::VERB_CRAZY, 'display help info for the method=%s, action=%s,...
[ "protected", "function", "showHelpByMethodAnnotations", "(", "string", "$", "method", ",", "string", "$", "action", "=", "''", ",", "array", "$", "aliases", "=", "[", "]", ")", ":", "int", "{", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", ...
Display command/action help by parse method annotations @param string $method @param string $action @param array $aliases @return int @throws \ReflectionException
[ "Display", "command", "/", "action", "help", "by", "parse", "method", "annotations" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L496-L574
inhere/php-console
src/AbstractHandler.php
AbstractHandler.getVerbLevel
public function getVerbLevel(): int { if ($this->app) { return $this->app->getVerbLevel(); } return (int)$this->input->getLongOpt('debug', Console::VERB_ERROR); }
php
public function getVerbLevel(): int { if ($this->app) { return $this->app->getVerbLevel(); } return (int)$this->input->getLongOpt('debug', Console::VERB_ERROR); }
[ "public", "function", "getVerbLevel", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "app", ")", "{", "return", "$", "this", "->", "app", "->", "getVerbLevel", "(", ")", ";", "}", "return", "(", "int", ")", "$", "this", "->", "input", "...
get current debug level value @return int
[ "get", "current", "debug", "level", "value" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/AbstractHandler.php#L663-L670
inhere/php-console
examples/Command/CorCommand.php
CorCommand.execute
protected function execute($input, $output) { $output->aList([ 'support coroutine?' => Helper::isSupportCoroutine() ? 'Y' : 'N', 'open coroutine running?' => self::isCoroutine() ? 'Y' : 'N', 'running in coroutine?' => Helper::inCoroutine() ? 'Y' : 'N', ], 'some in...
php
protected function execute($input, $output) { $output->aList([ 'support coroutine?' => Helper::isSupportCoroutine() ? 'Y' : 'N', 'open coroutine running?' => self::isCoroutine() ? 'Y' : 'N', 'running in coroutine?' => Helper::inCoroutine() ? 'Y' : 'N', ], 'some in...
[ "protected", "function", "execute", "(", "$", "input", ",", "$", "output", ")", "{", "$", "output", "->", "aList", "(", "[", "'support coroutine?'", "=>", "Helper", "::", "isSupportCoroutine", "(", ")", "?", "'Y'", ":", "'N'", ",", "'open coroutine running?'...
do execute @param Input $input @param Output $output
[ "do", "execute" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/examples/Command/CorCommand.php#L39-L46
inhere/php-console
src/Component/Style/Color.php
Color.makeByString
public static function makeByString($string) { $fg = $bg = ''; $extra = false; $options = []; $parts = \explode(';', \str_replace(' ', '', $string)); foreach ($parts as $part) { $subParts = \explode('=', $part); if (\count($subParts) < 2) { ...
php
public static function makeByString($string) { $fg = $bg = ''; $extra = false; $options = []; $parts = \explode(';', \str_replace(' ', '', $string)); foreach ($parts as $part) { $subParts = \explode('=', $part); if (\count($subParts) < 2) { ...
[ "public", "static", "function", "makeByString", "(", "$", "string", ")", "{", "$", "fg", "=", "$", "bg", "=", "''", ";", "$", "extra", "=", "false", ";", "$", "options", "=", "[", "]", ";", "$", "parts", "=", "\\", "explode", "(", "';'", ",", "...
Create a color style from a parameter string. @param string $string e.g 'fg=white;bg=black;options=bold,underscore;extra=1' @return static @throws \InvalidArgumentException @throws \RuntimeException
[ "Create", "a", "color", "style", "from", "a", "parameter", "string", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Style/Color.php#L102-L136
inhere/php-console
src/Component/Style/Color.php
Color.toStyle
public function toStyle(): string { $values = []; if ($this->fgColor) { $values[] = $this->fgColor; } if ($this->bgColor) { $values[] = $this->bgColor; } foreach ($this->options as $option) { $values[] = static::$knownOptions[$op...
php
public function toStyle(): string { $values = []; if ($this->fgColor) { $values[] = $this->fgColor; } if ($this->bgColor) { $values[] = $this->bgColor; } foreach ($this->options as $option) { $values[] = static::$knownOptions[$op...
[ "public", "function", "toStyle", "(", ")", ":", "string", "{", "$", "values", "=", "[", "]", ";", "if", "(", "$", "this", "->", "fgColor", ")", "{", "$", "values", "[", "]", "=", "$", "this", "->", "fgColor", ";", "}", "if", "(", "$", "this", ...
Get the translated color code.
[ "Get", "the", "translated", "color", "code", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Style/Color.php#L199-L216
inhere/php-console
src/IO/Output.php
Output.stopBuffer
public function stopBuffer(bool $flush = true, $nl = false, $quit = false, array $opts = []): void { Console::stopBuffer($flush, $nl, $quit, $opts); }
php
public function stopBuffer(bool $flush = true, $nl = false, $quit = false, array $opts = []): void { Console::stopBuffer($flush, $nl, $quit, $opts); }
[ "public", "function", "stopBuffer", "(", "bool", "$", "flush", "=", "true", ",", "$", "nl", "=", "false", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "void", "{", "Console", "::", "stopBuffer", "(", "$", "f...
stop buffering and flush buffer text {@inheritdoc} @see Console::stopBuffer()
[ "stop", "buffering", "and", "flush", "buffer", "text", "{" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/Output.php#L84-L87
inhere/php-console
src/IO/Output.php
Output.flush
public function flush(bool $nl = false, $quit = false, array $opts = []): void { Console::flushBuffer($nl, $quit, $opts); }
php
public function flush(bool $nl = false, $quit = false, array $opts = []): void { Console::flushBuffer($nl, $quit, $opts); }
[ "public", "function", "flush", "(", "bool", "$", "nl", "=", "false", ",", "$", "quit", "=", "false", ",", "array", "$", "opts", "=", "[", "]", ")", ":", "void", "{", "Console", "::", "flushBuffer", "(", "$", "nl", ",", "$", "quit", ",", "$", "o...
stop buffering and flush buffer text {@inheritdoc}
[ "stop", "buffering", "and", "flush", "buffer", "text", "{" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/Output.php#L93-L96
inhere/php-console
src/IO/Output.php
Output.read
public function read(string $question = '', bool $nl = false): string { return Console::read($question, $nl); }
php
public function read(string $question = '', bool $nl = false): string { return Console::read($question, $nl); }
[ "public", "function", "read", "(", "string", "$", "question", "=", "''", ",", "bool", "$", "nl", "=", "false", ")", ":", "string", "{", "return", "Console", "::", "read", "(", "$", "question", ",", "$", "nl", ")", ";", "}" ]
Read input information @param string $question 若不为空,则先输出文本 @param bool $nl true 会添加换行符 false 原样输出,不添加换行符 @return string
[ "Read", "input", "information" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/Output.php#L108-L111
inhere/php-console
src/IO/Output.php
Output.stderr
public function stderr(string $text = '', $nl = true): int { return Console::write($text, $nl, [ 'steam' => $this->errorStream, ]); }
php
public function stderr(string $text = '', $nl = true): int { return Console::write($text, $nl, [ 'steam' => $this->errorStream, ]); }
[ "public", "function", "stderr", "(", "string", "$", "text", "=", "''", ",", "$", "nl", "=", "true", ")", ":", "int", "{", "return", "Console", "::", "write", "(", "$", "text", ",", "$", "nl", ",", "[", "'steam'", "=>", "$", "this", "->", "errorSt...
Write a message to standard error output stream. @param string $text @param boolean $nl True (default) to append a new line at the end of the output string. @return int
[ "Write", "a", "message", "to", "standard", "error", "output", "stream", "." ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/IO/Output.php#L119-L124
inhere/php-console
src/Component/Formatter/HelpPanel.php
HelpPanel.show
public static function show(array $config): void { $parts = []; $option = [ 'indentDes' => ' ', ]; $config = \array_merge([ 'description' => '', 'usage' => '', 'commands' => [], 'arguments' => [], 'opti...
php
public static function show(array $config): void { $parts = []; $option = [ 'indentDes' => ' ', ]; $config = \array_merge([ 'description' => '', 'usage' => '', 'commands' => [], 'arguments' => [], 'opti...
[ "public", "static", "function", "show", "(", "array", "$", "config", ")", ":", "void", "{", "$", "parts", "=", "[", "]", ";", "$", "option", "=", "[", "'indentDes'", "=>", "' '", ",", "]", ";", "$", "config", "=", "\\", "array_merge", "(", "[", ...
Show console help message @param array $config The config data There are config structure. you can setting some or ignore some. will only render it when value is not empty. [ description string The description text. e.g 'Composer version 1.3.2' usage string The usage message text. e.g 'command [o...
[ "Show", "console", "help", "message" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Formatter/HelpPanel.php#L64-L130
inhere/php-console
src/Component/Interact/LimitedAsk.php
LimitedAsk.ask
public static function ask( string $question, string $default = '', \Closure $validator = null, int $times = 3 ): string { if (!$question = \trim($question)) { Show::error('Please provide a question text!', 1); } $answer = ''; $back = $t...
php
public static function ask( string $question, string $default = '', \Closure $validator = null, int $times = 3 ): string { if (!$question = \trim($question)) { Show::error('Please provide a question text!', 1); } $answer = ''; $back = $t...
[ "public", "static", "function", "ask", "(", "string", "$", "question", ",", "string", "$", "default", "=", "''", ",", "\\", "Closure", "$", "validator", "=", "null", ",", "int", "$", "times", "=", "3", ")", ":", "string", "{", "if", "(", "!", "$", ...
Ask a question, ask for a limited number of times 若输入了值且验证成功则返回 输入的结果 否则,会连续询问 $times 次, 若仍然错误,退出 @param string $question 问题 @param string $default 默认值 @param \Closure $validator (默认验证输入是否为空)自定义回调验证输入是否符合要求; 验证成功返回true 否则 可返回错误消息 @example This is an example ```php // no default value Interact::limitedAsk('please e...
[ "Ask", "a", "question", "ask", "for", "a", "limited", "number", "of", "times", "若输入了值且验证成功则返回", "输入的结果", "否则,会连续询问", "$times", "次,", "若仍然错误,退出", "@param", "string", "$question", "问题", "@param", "string", "$default", "默认值", "@param", "\\", "Closure", "$validator"...
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Interact/LimitedAsk.php#L50-L107
inhere/php-console
src/Component/Interact/Password.php
Password.ask
public static function ask(string $prompt = 'Enter Password:'): string { $prompt = $prompt ? \addslashes($prompt) : 'Enter:'; // $checkCmd = "/usr/bin/env bash -c 'echo OK'"; // $shell = 'echo $0'; // linux, unix, git-bash if (Sys::shIsAvailable()) { // COMMAND:...
php
public static function ask(string $prompt = 'Enter Password:'): string { $prompt = $prompt ? \addslashes($prompt) : 'Enter:'; // $checkCmd = "/usr/bin/env bash -c 'echo OK'"; // $shell = 'echo $0'; // linux, unix, git-bash if (Sys::shIsAvailable()) { // COMMAND:...
[ "public", "static", "function", "ask", "(", "string", "$", "prompt", "=", "'Enter Password:'", ")", ":", "string", "{", "$", "prompt", "=", "$", "prompt", "?", "\\", "addslashes", "(", "$", "prompt", ")", ":", "'Enter:'", ";", "// $checkCmd = \"/usr/bin/env ...
Interactively prompts for input without echoing to the terminal. Requires a bash shell or Windows and won't work with safe_mode settings (Uses `shell_exec`) @param string $prompt @return string @link https://stackoverflow.com/questions/187736/command-line-password-prompt-in-php @link http://www.sitepoint.com/blogs/2009...
[ "Interactively", "prompts", "for", "input", "without", "echoing", "to", "the", "terminal", ".", "Requires", "a", "bash", "shell", "or", "Windows", "and", "won", "t", "work", "with", "safe_mode", "settings", "(", "Uses", "shell_exec", ")" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/Component/Interact/Password.php#L24-L55
inhere/php-console
src/BuiltIn/PharController.php
PharController.packCommand
public function packCommand($in, $out): int { $time = \microtime(1); $workDir = $in->getPwd(); $dir = $in->getOpt('dir') ?: $workDir; $cpr = $this->configCompiler($dir); $counter = null; $refresh = $in->boolOpt('refresh'); $pharFile = $workDir . '/' . $in->s...
php
public function packCommand($in, $out): int { $time = \microtime(1); $workDir = $in->getPwd(); $dir = $in->getOpt('dir') ?: $workDir; $cpr = $this->configCompiler($dir); $counter = null; $refresh = $in->boolOpt('refresh'); $pharFile = $workDir . '/' . $in->s...
[ "public", "function", "packCommand", "(", "$", "in", ",", "$", "out", ")", ":", "int", "{", "$", "time", "=", "\\", "microtime", "(", "1", ")", ";", "$", "workDir", "=", "$", "in", "->", "getPwd", "(", ")", ";", "$", "dir", "=", "$", "in", "-...
pack project to a phar package @usage {fullCommand} [--dir DIR] [--output FILE] [...] @options -d, --dir STRING Setting the project directory for packing. default is current work-dir.(<cyan>{workDir}</cyan>) -c, --config STRING Use the custom config file for build phar(<cyan>./phar.build.inc</cyan>) -o, --ou...
[ "pack", "project", "to", "a", "phar", "package" ]
train
https://github.com/inhere/php-console/blob/d08a0a70fbcfecf6289db6b1a23582eeff32d4a7/src/BuiltIn/PharController.php#L55-L112