2013-01-12 22:42:05 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// Red cli interpreter
|
|
|
|
|
|
|
|
require_once('include/cli_startup.php');
|
2013-01-12 23:55:37 +00:00
|
|
|
require_once('include/zot.php');
|
2013-01-12 22:42:05 +00:00
|
|
|
|
|
|
|
cli_startup();
|
|
|
|
|
|
|
|
$prompt = 'fresh% ';
|
|
|
|
|
|
|
|
function fresh_main($argc,$argv) {
|
|
|
|
global $prompt;
|
|
|
|
|
|
|
|
while(!feof(STDIN)) {
|
|
|
|
|
|
|
|
|
|
|
|
if(function_exists('readline'))
|
|
|
|
$line = readline($prompt);
|
|
|
|
else {
|
|
|
|
echo "\n" . $prompt;
|
|
|
|
$line = fgets(STDIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($line === FALSE) {
|
|
|
|
if(feof(STDIN)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line = trim($line);
|
|
|
|
if($line == 'quit' || $line == 'exit')
|
|
|
|
exit();
|
|
|
|
process_command($line);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fresh_main($argc,$argv);
|
|
|
|
|
|
|
|
function process_command($line) {
|
|
|
|
|
2013-01-12 23:55:37 +00:00
|
|
|
$a = get_app();
|
|
|
|
|
2013-01-12 22:42:05 +00:00
|
|
|
// split args
|
|
|
|
|
2013-01-12 23:55:37 +00:00
|
|
|
$a->cmd = $line;
|
|
|
|
$a->argv = explode(' ',$line);
|
|
|
|
$a->argc = count($a->argv);
|
|
|
|
|
|
|
|
$authenticated = false;
|
|
|
|
$channel = null;
|
|
|
|
|
2013-01-12 22:42:05 +00:00
|
|
|
if($line == 'version') {
|
|
|
|
echo 'Fresh version 0.1';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-12 23:55:37 +00:00
|
|
|
switch(argv(0)) {
|
|
|
|
case 'finger':
|
|
|
|
if(argv(1)) {
|
|
|
|
$x = zot_finger(argv(1),$channel);
|
|
|
|
if($x['success'])
|
|
|
|
print_r(json_decode($x['body'],true));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-01-12 22:42:05 +00:00
|
|
|
|
2013-01-12 23:55:37 +00:00
|
|
|
}
|
2013-01-12 22:42:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|