コード例 #1
0
 function tag($args = [])
 {
     if (isset($args[0])) {
         $arg = array_shift($args);
         if ($arg == 'init') {
             $tags = [];
             foreach ($this->urls as $url => $data) {
                 foreach ($data['tags'] as $tag) {
                     $tags[] = $tag;
                 }
             }
             $tags = array_unique($tags);
             sort($tags);
             if (0 != filesize(TAG_FILE)) {
                 err(TAG_FILE . " contains tag entries. Manually truncate the file first.");
             } else {
                 $tag_len = count($tags);
                 $filtered_tags = [];
                 foreach ($tags as $tK => $tV) {
                     $i = $tK + 1;
                     $tbl = new Console_Table();
                     $tbl->addRow(array("[{$i}/{$tag_len}]", $tV, " subscribe? (y/n)"));
                     echo $tbl->getTable();
                     //send the cursor back up a line to answer yes or no.
                     echo chr(27) . "[" . 2 . "A" . "\t\t\t\t\t\t\t";
                     $ans = strtolower(Seld\CliPrompt\CliPrompt::prompt());
                     if ($ans == 'y' || $ans == 'yes') {
                         $filtered_tags[] = $tV;
                     }
                 }
                 file_put_contents(TAG_FILE, implode(PHP_EOL, $filtered_tags));
                 suc("wrote default tags into " . TAG_FILE);
             }
         } else {
             if ($arg == 'update') {
                 //not written yet.
             }
         }
     } else {
         err("<tag init> and <tag update> are available.");
     }
 }
コード例 #2
0
ファイル: example.php プロジェクト: aleksabp/bolt
<?php

require __DIR__ . '/../vendor/autoload.php';
echo 'Say hello (visible): ';
$answer = Seld\CliPrompt\CliPrompt::prompt();
echo 'You answered: ' . $answer . PHP_EOL;
echo 'Say hello (hidden): ';
$answer = Seld\CliPrompt\CliPrompt::hiddenPrompt();
echo 'You answered: ' . $answer . PHP_EOL;