예제 #1
0
파일: assets.php 프로젝트: just-paja/fudjan
 public function cmd_list()
 {
     \System\Init::basic();
     $list = cfg('assets', 'dependencies');
     if ($this->json) {
         \Helper\Cli::out(json_encode(array("dependencies" => $list), JSON_PRETTY_PRINT));
     } else {
         \Helper\Cli::out('Bower dependencies');
         \Helper\Cli::out_flist(array("list" => $list, "margin" => 2));
     }
 }
예제 #2
0
파일: test.php 프로젝트: just-paja/fudjan
 public static function cmd_all()
 {
     \System\Init::basic();
     $all = self::get_all();
     $path = \System\Composer::resolve('/etc/init.d/test.php');
     foreach ($all as $key => $val) {
         $cmd = implode(';', array("cd '" . BASE_DIR . "'", "phpunit --bootstrap '" . $path . "' --colors --test-suffix .php '" . $val . "'"));
         \Helper\Cli::out($val);
         $out = passthru($cmd);
         \Helper\Cli::out();
     }
 }
예제 #3
0
 public function cmd_pair()
 {
     \System\Init::full();
     $token = \System\Settings::get('bank', 'token');
     $from = \System\Settings::get('bank', 'from');
     $to = date('Y-m-d');
     $url = str_replace('{token}', $token, self::URL_TRANSACTIONS);
     $url = str_replace('{from}', $from, $url);
     $url = str_replace('{to}', $to, $url);
     $res = \Helper\Offcom\Request::get($url);
     if (!$res->ok()) {
         if ($res->status == 409) {
             \Helper\Cli::out('Please wait 30 seconds and try again.');
             exit(4);
         } else {
             \Helper\Cli::out('Unknown error during transaction scrape.');
             exit(5);
         }
     }
     $feed = \System\Json::decode($res->content);
     \Workshop\Payment::pair_with_feed($feed);
 }
예제 #4
0
파일: info.php 프로젝트: just-paja/fudjan
 public static function cmd_database()
 {
     \System\Init::full();
     $db_list = \System\Settings::get('database', 'list');
     foreach ($db_list as $db_ident => $db_cfg) {
         $size = \System\Database::query("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tsum(data_length + index_length) 'size',\n\t\t\t\t\t\t\tsum( data_free ) 'free'\n\t\t\t\t\t\tFROM information_schema.TABLES\n\t\t\t\t\t\tWHERE table_schema = '" . $db_cfg['database'] . "'\n\t\t\t\t\t\tGROUP BY table_schema;\n\t\t\t\t")->fetch();
         $mlast_date = false;
         $mcount = 0;
         try {
             $mig = \System\Database\Migration::get_new();
             $mcount = count($mig);
             $stat = "Ok";
             $mlast = \System\Database\Migration::get_first()->where(array("status" => 'ok'))->sort_by("updated_at DESC")->fetch();
             if ($mlast) {
                 $mlast_date = $mlast->updated_at;
             }
         } catch (System\Error $e) {
             $stat = "Migrating database is necessary.";
         }
         \Helper\Cli::out('Database ' . $db_ident);
         \Helper\Cli::sep();
         \Helper\Cli::out_flist(array("list" => array("Driver" => $db_cfg['driver'], "Host name" => $db_cfg['host'], "Database name" => $db_cfg['database'], "User" => $db_cfg['username'], "Used charset" => $db_cfg['charset'], "Lazy driver" => $db_cfg['lazy'] ? 'yes' : 'no', "Size" => \System\Template::convert_value('information', $size['size']), "Free space" => \System\Template::convert_value('information', $size['free']), "Structure" => $stat, "Last migrated" => $mlast_date ? $mlast_date->format('Y-m-d H:i:s') : 'never', "New migrations" => $mcount)));
     }
 }
예제 #5
0
파일: cache.php 프로젝트: just-paja/fudjan
 /**
  * Build locales cache
  *
  * @return void
  */
 public function cmd_locales()
 {
     \System\Init::basic();
     \Helper\Cli::out('Building system locales');
     \System\Cache::build_locales();
 }
예제 #6
0
파일: cli.php 프로젝트: just-paja/fudjan
 /** Show progress bar on cli
  * @param int    $done       Count of items, that are done
  * @param int    $total      Total count of items
  * @param int    $size       Width of progress bar in chars
  * @param string $done_msg   Message that will be printed on finish
  * @param string $static_msg Message that will be printed during the process
  * @return void
  */
 public static function progress($done, $total, $msg = '', $msglen = null)
 {
     if ($done <= $total) {
         $size = self::get_width();
         $msglen = is_null($msglen) ? strlen($msg) : $msglen;
         $psize = abs($size - $msglen - 12);
         $perc = (double) ($done / $total);
         $bar = floor($perc * $psize);
         $status_bar = "\r  [";
         $status_bar .= str_repeat("=", $bar);
         if ($bar < $psize) {
             $status_bar .= ">";
             $status_bar .= str_repeat(" ", $psize - $bar - 1);
         } else {
             $status_bar .= "=";
         }
         $disp = number_format($perc * 100, 0);
         $status_bar .= "] {$disp}%";
         $left = $total - $done;
         $status_bar .= ": " . $msg;
         if (($blank = $size - strlen($status_bar)) > 0) {
             $status_bar .= str_repeat(' ', $blank);
         }
         echo $status_bar;
         flush();
         if ($done == $total) {
             \Helper\Cli::out();
         }
     }
 }
예제 #7
0
파일: module.php 프로젝트: just-paja/fudjan
 /** Display usage
  * @return void
  */
 public function usage()
 {
     $cmd_list = array();
     $opt_list = array();
     foreach ($this::$commands as $cmd => $info) {
         if (is_array($info)) {
             foreach ($info as $type => $desc) {
                 $cmd_list[$type == 'single' ? $cmd : $cmd . " '" . $type . "'"] = $desc;
             }
         } else {
             $cmd_list[$cmd] = $info;
         }
     }
     foreach ($this::$attrs as $opt => $info) {
         if (isset($info['desc'])) {
             $name = (isset($info['short']) ? '-' . $info['short'] . ' ' : '   ') . '--' . $opt;
             $opt_list[$name] = $info['desc'];
         }
     }
     \Helper\Cli::out(is_array($this::$info['head']) ? implode("\n", $this::$info['head']) : $this::$info['head']);
     \Helper\Cli::out();
     \Helper\Cli::out("Usage:");
     \Helper\Cli::out("  ./" . $this->get_name() . " " . $this::$accepts);
     \Helper\Cli::out("  ./" . $this->get_name() . " " . $this::$accepts . " [params]");
     \Helper\Cli::out();
     if (!empty($cmd_list)) {
         \Helper\Cli::out("Commands:");
         \Helper\Cli::out_flist(array("list" => $cmd_list, "semicolon" => false, "margin" => 2));
         \Helper\Cli::out();
     }
     if (!empty($opt_list)) {
         \Helper\Cli::out("Options:");
         \Helper\Cli::out_flist(array("list" => $opt_list, "semicolon" => false, "margin" => 2));
     }
     exit;
 }
예제 #8
0
파일: db.php 프로젝트: just-paja/fudjan
 public function cmd_reset()
 {
     $this->cmd_rebuild();
     \Helper\Cli::out();
     $this->cmd_seed();
     return $this;
 }