-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.php
executable file
·43 lines (34 loc) · 1.47 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/php
<?php
ini_set('display_errors', 1);
include('PhpCli.class.php');
$options = array(array('v', 'Verbose Message', false),
array('date', 'Date of Report (YYYY-MM-DD)', true, '[0-9]{4}-[0-9]{2}-[0-9]{2}'));
$phpCli = new PhpCli($argv, $options, "This is an example script.");
echo "\r\nHas Option v? " . serialize($phpCli->hasArg('v'));
echo "\r\nHas Option date? " . serialize($phpCli->hasArg('date'));
echo "\r\nHas Option notreal? " . serialize($phpCli->hasArg('notreal'));
echo "\r\n";
echo "\r\nArg value for v? " . serialize($phpCli->getArgValue('v'));
echo "\r\nArg value for date? " . serialize($phpCli->getArgValue('date'));
echo "\r\nArg value for notreal? " . serialize($phpCli->getArgValue('notreal'));
echo "\r\n";
echo "\r\n";
$phpCli->printLine("Messsage with no special color.");
$phpCli->printLine("Messsage with special color.", 'blue', 'light_gray');
echo "\r\n";
$phpCli->printLine("This script is using ". $phpCli->getMemoryUsage() . " of memory.");
echo "\r\n";
echo "Progress Bar Example:";
$phpCli->progressStart(50);
$i = 0;
while($i < 50)
{
$i++;
$phpCli->progressNext();
usleep(100000);
}
$phpCli->progressStop();
//prompt the user for input
$this_is_my_name = $phpCli->promptInput("What is your name?");
echo "Hello, " . $this_is_my_name . '!' . PHP_EOL . PHP_EOL;