Skip to content

Instantly share code, notes, and snippets.

@uzulla
Created April 26, 2014 19:38
Show Gist options
  • Save uzulla/11329033 to your computer and use it in GitHub Desktop.
Save uzulla/11329033 to your computer and use it in GitHub Desktop.
PHPでCLIのプログレスバーっぽいやつをつくる件 例:http://pyazo.cdn.cfe.jp/image/zFrO88JGgrj4fUJN139854090597644.gif
{
"require": {
"donatj/cli-toolkit": "dev-master"
}
}
#!/usr/bin/env php
<?php
require "vendor/autoload.php";
CLI\Erase::screen();
$w = 10; //CLI\Misc::cols();
$kuru = ['-','\\','|','/'];
$kuru_num = count($kuru);
while(1){
for($i=1;$i<=$w;$i++){
usleep(100000);
CLI\Erase::screen();
CLI\Graphics::line(1, 1, $i, 1, ['=']);
CLI\Output::string('>');
CLI\Graphics::line(1, 13-$i, 1, 13, ['|']);
CLI\Output::string('^', 12-$i, 1);
CLI\Output::string(sprintf("%3d%%", $i*10), 3,3);
CLI\Output::string($kuru[$i%$kuru_num], 5,5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment