- Refactor of all the MindCommand class
- Rebuilt of all programs to use the pattern of the new format designed for the new MindCommand class
|
Antes Largura: | Altura: | Tamanho: 694 KiB Depois Largura: | Altura: | Tamanho: 694 KiB |
|
Antes Largura: | Altura: | Tamanho: 464 KiB Depois Largura: | Altura: | Tamanho: 464 KiB |
|
Antes Largura: | Altura: | Tamanho: 825 KiB Depois Largura: | Altura: | Tamanho: 825 KiB |
|
Antes Largura: | Altura: | Tamanho: 602 KiB Depois Largura: | Altura: | Tamanho: 602 KiB |
|
Antes Largura: | Altura: | Tamanho: 342 KiB Depois Largura: | Altura: | Tamanho: 342 KiB |
|
Antes Largura: | Altura: | Tamanho: 107 KiB Depois Largura: | Altura: | Tamanho: 107 KiB |
|
Antes Largura: | Altura: | Tamanho: 254 KiB Depois Largura: | Altura: | Tamanho: 254 KiB |
|
Antes Largura: | Altura: | Tamanho: 19 KiB Depois Largura: | Altura: | Tamanho: 19 KiB |
|
Antes Largura: | Altura: | Tamanho: 36 KiB Depois Largura: | Altura: | Tamanho: 36 KiB |
|
Antes Largura: | Altura: | Tamanho: 1.1 KiB Depois Largura: | Altura: | Tamanho: 1.1 KiB |
|
Antes Largura: | Altura: | Tamanho: 12 KiB Depois Largura: | Altura: | Tamanho: 12 KiB |
|
Antes Largura: | Altura: | Tamanho: 1.8 KiB Depois Largura: | Altura: | Tamanho: 1.8 KiB |
|
Antes Largura: | Altura: | Tamanho: 1.5 KiB Depois Largura: | Altura: | Tamanho: 1.5 KiB |
@@ -80,8 +80,7 @@
|
|||||||
type:'POST',
|
type:'POST',
|
||||||
url:'../../',
|
url:'../../',
|
||||||
data:{
|
data:{
|
||||||
program:'test',
|
program:'test'
|
||||||
unit: true
|
|
||||||
},
|
},
|
||||||
success: function(ret){
|
success: function(ret){
|
||||||
document.getElementById('result').innerHTML= ret
|
document.getElementById('result').innerHTML= ret
|
||||||
@@ -146,7 +145,7 @@
|
|||||||
data:{
|
data:{
|
||||||
program:'use',
|
program:'use',
|
||||||
what:'project',
|
what:'project',
|
||||||
name:'demo_en'
|
projectName:'demo_en'
|
||||||
},
|
},
|
||||||
success: function(ret){
|
success: function(ret){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -240,7 +239,7 @@
|
|||||||
url:'../../',
|
url:'../../',
|
||||||
data:{
|
data:{
|
||||||
program:'generate',
|
program:'generate',
|
||||||
what: 'db'
|
lobe: 'db'
|
||||||
},
|
},
|
||||||
success: function(retQ){
|
success: function(retQ){
|
||||||
document.getElementById('result').innerHTML= retQ;
|
document.getElementById('result').innerHTML= retQ;
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
adicionar ao relatório, a definição detalhada da API, seus
|
|
||||||
métodos e parâmetros(ja tentando facilitar para a criação
|
|
||||||
da documentação para os usuarios/contribuidores).
|
|
||||||
@@ -53,6 +53,13 @@ class En implements l10n{
|
|||||||
$this->messages['theosDBQrFailAbort'] = Mind::message("Theos: All the queries will be aborted", '[Fail]', false);
|
$this->messages['theosDBQrFailAbort'] = Mind::message("Theos: All the queries will be aborted", '[Fail]', false);
|
||||||
$this->messages['theosDBQrOk'] = Mind::message("Theos: Database created successfuly", '[Ok]', false);
|
$this->messages['theosDBQrOk'] = Mind::message("Theos: Database created successfuly", '[Ok]', false);
|
||||||
$this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver not found", '[Fail]', false);
|
$this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver not found", '[Fail]', false);
|
||||||
|
$this->messages['missingParameter'] = Mind::message("API: Missing argument: %s", '[Fail]', false);
|
||||||
|
$this->messages['done'] = Mind::message("API: Done\n", '[Ok]', false);
|
||||||
|
$this->messages['invalidOptionValue'] = Mind::message("API: %s is not a valid option for %s", '[Fail]', false);
|
||||||
|
$this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\n";
|
||||||
|
$this->messages['phpunitNotFound'] = "You must specify where to find phpUnit classes\n".
|
||||||
|
"You can configure it on mind3rd/env/mind.ini ini file\n".
|
||||||
|
"changing the phpunit-src ini property\n";;
|
||||||
|
|
||||||
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
||||||
Invalid HTTP requisition.
|
Invalid HTTP requisition.
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ class pt implements l10n{
|
|||||||
$this->messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false);
|
$this->messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false);
|
||||||
$this->messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false);
|
$this->messages['theosDBQrOk'] = Mind::message("Theos: Base de dados gerada com sucesso", '[Ok]', false);
|
||||||
$this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver não encontrado", '[Fail]', false);
|
$this->messages['dbDriverNotFound'] = Mind::message("Theos: Database Driver não encontrado", '[Fail]', false);
|
||||||
|
$this->messages['missingParameter'] = Mind::message("API: Argumento faltando: %s", '[Fail]', false);
|
||||||
|
$this->messages['done'] = Mind::message("API: Pronto\n", '[Ok]', false);
|
||||||
|
$this->messages['invalidOptionValue'] = Mind::message("API: %s não é uma opção válida para %s", '[Fail]', false);
|
||||||
|
$this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\n";
|
||||||
|
$this->messages['phpunitNotFound'] = "Especifique onde encontram-se as classes do PHPUnit\n".
|
||||||
|
"Você pode configurar isto em mind3rd/env/mind.ini ini file\n".
|
||||||
|
"alterando a propriedade phpunit-src\n";
|
||||||
|
|
||||||
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
$this->messages['http_invalid_requisition'] = <<<MESSAGE
|
||||||
Requisição HTTP inválida.
|
Requisição HTTP inválida.
|
||||||
|
|||||||
@@ -43,15 +43,10 @@ class db extends \Lobe\Neuron implements \neuron{
|
|||||||
|
|
||||||
foreach($qrs['createTable'] as $tbName=>$qrObject)
|
foreach($qrs['createTable'] as $tbName=>$qrObject)
|
||||||
{
|
{
|
||||||
//foreach($qrType as $qr)
|
if(!$dealer->createTable($qrObject))
|
||||||
//{
|
{
|
||||||
//print_r($qr);
|
return false;
|
||||||
if(!$dealer->createTable($qrObject))
|
}
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
$this->dbal->commit();
|
$this->dbal->commit();
|
||||||
\Mind::write('theosDBQrOk');
|
\Mind::write('theosDBQrOk');
|
||||||
|
|||||||
@@ -18,15 +18,16 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
|||||||
private $requiredOptions = Array();
|
private $requiredOptions = Array();
|
||||||
private $optionalOptions = Array();
|
private $optionalOptions = Array();
|
||||||
private $commandFlags = Array();
|
private $commandFlags = Array();
|
||||||
|
public $answers = Array();
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
//$this->configure();
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
|
$this->setDefinition(Array());
|
||||||
$this->setName($this->commandName);
|
$this->setName($this->commandName);
|
||||||
|
|
||||||
$definition= Array();
|
$definition= Array();
|
||||||
@@ -39,6 +40,78 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
|||||||
$this->setDefinition($definition);
|
$this->setDefinition($definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function prompt($name, $question, $mode=false)
|
||||||
|
{
|
||||||
|
GLOBAL $_REQ;
|
||||||
|
$secret= false;
|
||||||
|
$options= false;
|
||||||
|
|
||||||
|
if($mode)
|
||||||
|
{
|
||||||
|
if(is_array($mode))
|
||||||
|
{
|
||||||
|
$options= $mode;
|
||||||
|
}else
|
||||||
|
$secret= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$answer= null;
|
||||||
|
if($_REQ['env'] !='http')
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
echo $question."\n";
|
||||||
|
if($options)
|
||||||
|
{
|
||||||
|
echo "(";
|
||||||
|
$optionLegend= Array();
|
||||||
|
foreach($options as $optVal=>$optLabel)
|
||||||
|
{
|
||||||
|
$optionLegend[]= $optVal."=".$optLabel;
|
||||||
|
}
|
||||||
|
echo trim(implode(" |", $optionLegend));
|
||||||
|
echo ")\n";
|
||||||
|
}
|
||||||
|
if(!$secret)
|
||||||
|
{
|
||||||
|
$fp = fopen('php://stdin', 'r');
|
||||||
|
$answer = trim(fgets($fp, 1024));
|
||||||
|
|
||||||
|
if($options &&
|
||||||
|
!in_array(strtolower($answer),
|
||||||
|
array_map('strtolower', array_keys($options))))
|
||||||
|
{
|
||||||
|
Mind::write('invalidOptionValue', true, $answer, $name);
|
||||||
|
$answer= false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$answer= $this->readPassword('*');
|
||||||
|
}
|
||||||
|
}while(!$answer);
|
||||||
|
}else{
|
||||||
|
if(isset($_POST[$name]))
|
||||||
|
{
|
||||||
|
$answer= $_POST[$name];
|
||||||
|
|
||||||
|
if($options &&
|
||||||
|
!in_array(strtolower($answer),
|
||||||
|
array_map('strtolower', $options)))
|
||||||
|
{
|
||||||
|
Mind::write('invalidOptionValue', true, $answer, $name);
|
||||||
|
$answer= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$answer)
|
||||||
|
{
|
||||||
|
Mind::write('missingParameter', true, $name);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->answers[$name]= trim($answer);
|
||||||
|
return $this->answers[$name];
|
||||||
|
}
|
||||||
|
|
||||||
public function addRequiredArgument($argName, $agDescription='')
|
public function addRequiredArgument($argName, $agDescription='')
|
||||||
{
|
{
|
||||||
$this->requiredArguments[]= new InputArgument($argName,
|
$this->requiredArguments[]= new InputArgument($argName,
|
||||||
@@ -75,9 +148,9 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
|||||||
public function addFlag($name, $shortCut=null, $description='')
|
public function addFlag($name, $shortCut=null, $description='')
|
||||||
{
|
{
|
||||||
$this->commandFlags[]= new InputOption($name,
|
$this->commandFlags[]= new InputOption($name,
|
||||||
$shortCut,
|
$shortCut,
|
||||||
InputOption::PARAMETER_NONE,
|
InputOption::PARAMETER_NONE,
|
||||||
$description);
|
$description);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +277,10 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
|||||||
{
|
{
|
||||||
$this->$k= $arg;
|
$this->$k= $arg;
|
||||||
}
|
}
|
||||||
|
foreach($input->getOptions() as $k=>$opt)
|
||||||
|
{
|
||||||
|
$this->$k= $opt;
|
||||||
|
}
|
||||||
|
|
||||||
$this->runAction();
|
$this->runAction();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ namespace theos;
|
|||||||
*/
|
*/
|
||||||
final class ProjectFileManager {
|
final class ProjectFileManager {
|
||||||
|
|
||||||
|
public static function getLobesDir()
|
||||||
|
{
|
||||||
|
return _MINDSRC_."/mind3rd/API/Lobe/";
|
||||||
|
}
|
||||||
|
|
||||||
private static function filterURI($uri, $allowSlashes=true)
|
private static function filterURI($uri, $allowSlashes=true)
|
||||||
{
|
{
|
||||||
$uri= \urlencode(\utf8_encode($uri));
|
$uri= \urlencode(\utf8_encode($uri));
|
||||||
|
|||||||
@@ -15,48 +15,25 @@
|
|||||||
private $nameSpace= false;
|
private $nameSpace= false;
|
||||||
public $autoCommit= false;
|
public $autoCommit= false;
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('analyze')
|
$this->setCommandName('analyze')
|
||||||
->setDescription('Analyze the the code for your application')
|
->setDescription('Analyze the the code for your application')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
->setDefinition(Array(
|
->setAction('action')
|
||||||
new InputArgument('namespace', InputArgument::OPTIONAL, 'Analyze an specific namespace'),
|
|
||||||
new InputOption('commit', false, InputOption::PARAMETER_NONE, "Commit the result after analisys")
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
This program will analyze your code, typed on your application directory, on all the files .mnd starting for the main.mnd
|
This program will analyze your code, typed on your application directory, on all the files .mnd starting for the main.mnd
|
||||||
You may have as many files as you want, each of then will be treated as namespaces and will be analyzed too,
|
You may have as many files as you want, each of then will be treated as namespaces and will be analyzed too,
|
||||||
unless you have sent an specific namespace to parse, as argument
|
unless you have sent an specific namespace to parse, as argument
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
$this->addOptionalArgument('namespace', 'Analyze an specific namespace');
|
||||||
public function execute(Console\Input\InputInterface $input,
|
$this->addFlag('commit', false, "Commit the result after analisys");
|
||||||
Console\Output\OutputInterface $output)
|
|
||||||
{
|
$this->init();
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
$this->nameSpace= $input->getArgument('namespace');
|
|
||||||
$this->autoCommit= $input->getOption('commit');
|
|
||||||
Mind::write('thinking');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
if(isset($_REQ['data']['namespace']))
|
|
||||||
$this->nameSpace= $_REQ['data']['namespace'];
|
|
||||||
if(isset($_REQ['data']['commit']))
|
|
||||||
{
|
|
||||||
$this->autoCommit= $_REQ['data']['commit'];
|
|
||||||
}
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
if(!isset($_SESSION['currentProject']))
|
if(!isset($_SESSION['currentProject']))
|
||||||
{
|
{
|
||||||
@@ -64,14 +41,10 @@ EOT
|
|||||||
Mind::write('currentProjectRequiredTip');
|
Mind::write('currentProjectRequiredTip');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Mind::write('thinking');
|
||||||
MindProject::analyze($this->autoCommit? true: false);
|
MindProject::analyze($this->autoCommit? true: false);
|
||||||
|
//Mind::write('done');
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,75 +12,27 @@
|
|||||||
*/
|
*/
|
||||||
class Auth extends MindCommand implements program
|
class Auth extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public $login= null;
|
||||||
{
|
public $pwd= null;
|
||||||
$this->setName('auth')
|
|
||||||
->setDescription('Autenticate a user')
|
public function action()
|
||||||
->setRestrict(false)
|
|
||||||
->setDefinition(Array(
|
|
||||||
new InputArgument('login', InputArgument::REQUIRED, 'Login to access'),
|
|
||||||
new InputArgument('pwd', InputArgument::OPTIONAL, 'The user password')
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
|
||||||
Sets the user with a password.
|
|
||||||
It is required to autenticate, to run most of the commands
|
|
||||||
EOT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
public function execute(Console\Input\InputInterface $input,
|
|
||||||
Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
if(!$pw= $input->getArgument('pwd'))
|
|
||||||
{
|
|
||||||
Mind::write('passwordRequired', true);
|
|
||||||
$pw= Mind::readPassword(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->login= $input->getArgument('login');
|
|
||||||
$this->pwd= $pw;
|
|
||||||
if($this->runAction())
|
|
||||||
Mind::write('autenticated', true, $input->getArgument('login'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!isset($_REQ['data']))
|
|
||||||
{
|
|
||||||
Mind::write('loginRequired');
|
|
||||||
return false;
|
|
||||||
}elseif(!isset($_REQ['data']['pwd']) || !isset($_REQ['data']['login']))
|
|
||||||
{
|
|
||||||
Mind::write('loginRequired');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->pwd= $_REQ['data']['pwd'];
|
|
||||||
$this->login= $_REQ['data']['pwd'];
|
|
||||||
|
|
||||||
if($this->runAction())
|
|
||||||
Mind::write('autenticated', true, $_REQ['data']['login']);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
|
if(!$this->pwd)
|
||||||
|
$this->pwd= $this->prompt('pwd',
|
||||||
|
Mind::write('passwordRequired', false),
|
||||||
|
true);
|
||||||
|
|
||||||
if($db = new SQLite3(_MINDSRC_.'/mind3rd/SQLite/mind'))
|
if($db = new SQLite3(_MINDSRC_.'/mind3rd/SQLite/mind'))
|
||||||
{
|
{
|
||||||
$result= $db->query("SELECT * FROM user where login='".$this->login.
|
$result= $db->query("SELECT * FROM user where login='".$this->login.
|
||||||
"' AND pwd='".sha1($this->pwd)."' AND status= 'A'");
|
"' AND pwd='".sha1($this->pwd)."' AND status= 'A'");
|
||||||
$row= $result->fetchArray();
|
$row= $result->fetchArray();
|
||||||
/*while()
|
|
||||||
{
|
$_SESSION['auth']= JSON_encode($row);
|
||||||
$row = $result->current();*/
|
$_SESSION['pk_user']= $row['pk_user'];
|
||||||
$_SESSION['auth']= JSON_encode($row);
|
$_SESSION['status']= $row['status'];
|
||||||
$_SESSION['pk_user']= $row['pk_user'];
|
$_SESSION['login']= $row['login'];
|
||||||
$_SESSION['status']= $row['status'];
|
|
||||||
$_SESSION['login']= $row['login'];
|
|
||||||
/*break;
|
|
||||||
}*/
|
|
||||||
if(!$row)
|
if(!$row)
|
||||||
{
|
{
|
||||||
Mind::write('auth_fail', true);
|
Mind::write('auth_fail', true);
|
||||||
@@ -89,13 +41,25 @@ EOT
|
|||||||
}else{
|
}else{
|
||||||
die('Database not found!');
|
die('Database not found!');
|
||||||
}
|
}
|
||||||
|
Mind::write('autenticated', true, $this->login);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
$this->setCommandName('auth')
|
||||||
return $ret;
|
->setDescription('Autenticate a user')
|
||||||
}
|
->setRestrict(false)
|
||||||
|
->setAction('action')
|
||||||
|
->setHelp(<<<EOT
|
||||||
|
Sets the user with a password.
|
||||||
|
It is required to autenticate, to run most of the commands
|
||||||
|
EOT
|
||||||
|
);
|
||||||
|
$this->addRequiredArgument('login', 'Login to access');
|
||||||
|
$this->addOptionalArgument('pwd', 'The password may optionaly be passed');
|
||||||
|
|
||||||
|
$this->init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,34 +5,20 @@
|
|||||||
|
|
||||||
class Clear extends MindCommand implements program
|
class Clear extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('clear')
|
$this->setCommandName('clear')
|
||||||
->setDescription('Clears the console')
|
->setDescription('Clears the console')
|
||||||
->setDefinition(array())
|
->setRestrict(false)
|
||||||
|
->setAction('action')
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
Clears the console
|
Clears the console
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
|
$this->init();
|
||||||
}
|
}
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
public function action()
|
||||||
{
|
{
|
||||||
system('clear');
|
system('clear');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,35 +15,20 @@
|
|||||||
private $nameSpace= false;
|
private $nameSpace= false;
|
||||||
public $autoCommit= false;
|
public $autoCommit= false;
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('commit')
|
$this->setCommandName('commit')
|
||||||
->setDescription('Commits the analyzed content to a new version')
|
->setDescription('Commits the analyzed content to a new version')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
|
->setAction('action')
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
This command will increase the current version and also will persist the currently analyzed structure into the system's knowledge base.
|
This command will increase the current version and also will persist the currently analyzed structure into the system's knowledge base.
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
$this->init();
|
||||||
|
|
||||||
public function execute(Console\Input\InputInterface $input,
|
|
||||||
Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
Mind::write('thinking');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
if(!isset($_SESSION['currentProject']))
|
if(!isset($_SESSION['currentProject']))
|
||||||
{
|
{
|
||||||
@@ -54,11 +39,4 @@ EOT
|
|||||||
MindProject::analyze(true, false);
|
MindProject::analyze(true, false);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,81 +18,31 @@
|
|||||||
class Create extends MindCommand implements program
|
class Create extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public $what= null;
|
public $what= null;
|
||||||
public $argname= false;
|
public $argName= false;
|
||||||
public $info= "";
|
public $info= "";
|
||||||
private $userType= null;
|
private $userType= null;
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('create')
|
$this->setCommandName('create')
|
||||||
->setDescription('Create structures, such as project or user')
|
->setDescription('Create structures, such as project or user')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
->setDefinition(Array(
|
->setAction('action')
|
||||||
new InputArgument('what', InputArgument::REQUIRED, 'What to create'),
|
|
||||||
new InputArgument('name', InputArgument::REQUIRED, 'The refered name'),
|
|
||||||
new InputOption('info', '-i', InputOption::PARAMETER_OPTIONAL, 'Add extra information about the project')
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
You can create a new project by typing "create project name"
|
You can create a new project by typing "create project name"
|
||||||
You can create your users typing "create user name" and then, adding the user to any specific group.
|
You can create your users typing "create user name" and then, adding the user to any specific group.
|
||||||
You need to be a super user to perform these actions
|
You need to be a super user to perform these actions
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->addRequiredArgument('what', 'What to create');
|
||||||
|
$this->addRequiredArgument('argName', 'The refered name');
|
||||||
|
$this->addOptionalOption('into', '-i', 'Add extra information about what is being created');
|
||||||
|
|
||||||
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(Console\Input\InputInterface $input,
|
public function action()
|
||||||
Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
$this->what= $input->getArgument('what');
|
|
||||||
$this->argName= $input->getArgument('name');
|
|
||||||
|
|
||||||
if($this->what == 'user')
|
|
||||||
{
|
|
||||||
$this->info= $input->getOption('info');
|
|
||||||
echo "login: ";
|
|
||||||
$this->login= trim(fgets(fopen("php://stdin", "r")));
|
|
||||||
echo "pwd: ";
|
|
||||||
$this->pwd= Mind::readPassword(true);
|
|
||||||
echo "\n";
|
|
||||||
while($this->userType!='N' && $this->userType!='A')
|
|
||||||
{
|
|
||||||
echo "Type (use A for admin, or N for normal): ";
|
|
||||||
$this->userType= strtoupper(trim(fgets(fopen("php://stdin", "r"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->what= $_REQ['data']['what'];
|
|
||||||
$this->argName= $_REQ['data']['name'];
|
|
||||||
if(isset($_REQ['data']['info']))
|
|
||||||
$this->info= $_REQ['data']['info'];
|
|
||||||
if($this->what == 'user')
|
|
||||||
{
|
|
||||||
if(!isset($_REQ['data']['login'])
|
|
||||||
||
|
|
||||||
!isset($_REQ['data']['pwd'])
|
|
||||||
||
|
|
||||||
!isset($_REQ['data']['userType']))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->login= $_REQ['data']['login'];
|
|
||||||
$this->pwd= $_REQ['data']['pwd'];
|
|
||||||
$this->userType= $_REQ['data']['userType'];
|
|
||||||
}
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
GLOBAL $_MIND;
|
GLOBAL $_MIND;
|
||||||
switch($this->what)
|
switch($this->what)
|
||||||
@@ -115,10 +65,6 @@ EOT
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile);
|
|
||||||
|
|
||||||
chmod($this->projectfile, 0777);
|
|
||||||
|
|
||||||
$db= new MindDB();
|
$db= new MindDB();
|
||||||
$qr_newProj= "INSERT into project
|
$qr_newProj= "INSERT into project
|
||||||
(
|
(
|
||||||
@@ -147,7 +93,6 @@ EOT
|
|||||||
)";
|
)";
|
||||||
$db->execute($qr_userProj);
|
$db->execute($qr_userProj);
|
||||||
|
|
||||||
//Mind::$currentProject[''];
|
|
||||||
$iniSource= Mind::$projectsDir.$this->argName.'/mind.ini';
|
$iniSource= Mind::$projectsDir.$this->argName.'/mind.ini';
|
||||||
$cP= $_MIND->defaults;
|
$cP= $_MIND->defaults;
|
||||||
|
|
||||||
@@ -179,6 +124,9 @@ EOT
|
|||||||
$db->execute($qr_vsProj);
|
$db->execute($qr_vsProj);
|
||||||
$db->execute("COMMIT");
|
$db->execute("COMMIT");
|
||||||
|
|
||||||
|
Mind::copyDir(Mind::$modelsDir.'mind/', $this->projectfile);
|
||||||
|
chmod($this->projectfile, 0777);
|
||||||
|
|
||||||
Mind::write('projectCreated', true, $this->argName);
|
Mind::write('projectCreated', true, $this->argName);
|
||||||
|
|
||||||
$ini= file_get_contents($iniSource);
|
$ini= file_get_contents($iniSource);
|
||||||
@@ -195,14 +143,19 @@ EOT
|
|||||||
$this->argName.
|
$this->argName.
|
||||||
'/mind.ini',
|
'/mind.ini',
|
||||||
$ini);
|
$ini);
|
||||||
|
|
||||||
Mind::openProject(Array('pk_project'=>$key,
|
Mind::openProject(Array('pk_project'=>$key,
|
||||||
'name'=>$this->argName));
|
'name'=>$this->argName));
|
||||||
|
|
||||||
echo "\n";
|
|
||||||
break;
|
break;
|
||||||
case 'user':
|
case 'user':
|
||||||
$db= new MindDB();
|
$db= new MindDB();
|
||||||
|
$this->prompt('name', "What is the new user's name?");
|
||||||
|
$this->prompt('pwd', "What will be the password?", true);
|
||||||
|
$this->prompt('type',
|
||||||
|
"\nWill this user be an administrator?",
|
||||||
|
Array('Y'=>'Yes',
|
||||||
|
'N'=>'No'));
|
||||||
|
|
||||||
$qr_newUser= "INSERT into user
|
$qr_newUser= "INSERT into user
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@@ -213,11 +166,14 @@ EOT
|
|||||||
)
|
)
|
||||||
values
|
values
|
||||||
(
|
(
|
||||||
|
'".$this->answers['name']."',
|
||||||
'".addslashes($this->argName)."',
|
'".addslashes($this->argName)."',
|
||||||
'".$this->login."',
|
'".sha1($this->answers['pwd'])."',
|
||||||
'".sha1($this->pwd)."',
|
|
||||||
'A',
|
'A',
|
||||||
'".$this->userType."'
|
'".(strtoupper(
|
||||||
|
substr($this->answers['type'],
|
||||||
|
0,
|
||||||
|
1))=='Y'? 'A': 'N')."'
|
||||||
)";
|
)";
|
||||||
$db->execute($qr_newUser);
|
$db->execute($qr_newUser);
|
||||||
Mind::write('userCreated', true, $this->argName);
|
Mind::write('userCreated', true, $this->argName);
|
||||||
@@ -229,11 +185,4 @@ EOT
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,58 +12,46 @@
|
|||||||
*/
|
*/
|
||||||
class Generate extends MindCommand implements program
|
class Generate extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public $what;
|
public $lobe;
|
||||||
public $param;
|
public $param;
|
||||||
public $detail;
|
public $detail;
|
||||||
public $optional;
|
public $optional;
|
||||||
public $extra;
|
public $extra;
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('generate')
|
$dir= \theos\ProjectFileManager::getLobesDir();
|
||||||
->setDescription('Commits the analyzed content to a new version')
|
$d = dir($dir);
|
||||||
|
$options= Array();
|
||||||
|
while (false !== ($entry = $d->read())) {
|
||||||
|
if(is_dir($dir.$entry) && substr($entry, 0, 1) != '.')
|
||||||
|
$options[]= " >".$entry."\n";
|
||||||
|
}
|
||||||
|
$d->close();
|
||||||
|
|
||||||
|
$help= <<<EOT
|
||||||
|
will generate an output.
|
||||||
|
This program uses one(or more) of the Lobe classes to generate different
|
||||||
|
data, structure or output.
|
||||||
|
EOT;
|
||||||
|
$help.= "\n Currently installed Lobes:\n".implode("", $options);
|
||||||
|
|
||||||
|
$this->setCommandName('generate')
|
||||||
|
->setDescription('Generates different outputs')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
->setHelp(<<<EOT
|
->setAction('action')
|
||||||
This command will increase the current version and also will persist the currently analyzed structure into the system's knowledge base.
|
->setHelp($help);
|
||||||
EOT
|
|
||||||
)
|
$this->addRequiredArgument('lobe', 'Lobe to be used');
|
||||||
->setDefinition(Array(
|
$this->addOptionalArgument('param', 'A param for that command');
|
||||||
new InputArgument('what', InputArgument::REQUIRED, 'What to create'),
|
$this->addOptionalArgument('detail', 'A detail for that command');
|
||||||
new InputArgument('param', InputArgument::OPTIONAL, 'A param for that command'),
|
$this->addOptionalArgument('optional', 'An optional argument');
|
||||||
new InputArgument('detail', InputArgument::OPTIONAL, 'A detail for that command'),
|
$this->addOptionalArgument('extra', 'Extra data to be passed');
|
||||||
new InputArgument('optional', InputArgument::OPTIONAL, 'An optional argument'),
|
|
||||||
new InputArgument('extra', InputArgument::OPTIONAL, 'Extra data to pass'),
|
$this->init();
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(Console\Input\InputInterface $input,
|
|
||||||
Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
$this->what= $input->getArgument('what');
|
|
||||||
$this->param= $input->getArgument('param');
|
|
||||||
$this->detail= $input->getArgument('detail');
|
|
||||||
$this->optional= $input->getArgument('optional');
|
|
||||||
$this->extra= $input->getArgument('extra');
|
|
||||||
Mind::write('thinking');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
$this->what = $_REQ['data']['what'];
|
|
||||||
$this->param = (isset($_REQ['data']['param']))? $_REQ['data']['param']: false;
|
|
||||||
$this->detail = (isset($_REQ['data']['detail']))? $_REQ['data']['detail']: false;
|
|
||||||
$this->optional= (isset($_REQ['data']['optional']))? $_REQ['data']['optional']: false;
|
|
||||||
$this->extra = (isset($_REQ['data']['extra']))? $_REQ['data']['extra']: false;
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
if(!isset($_SESSION['currentProject']))
|
if(!isset($_SESSION['currentProject']))
|
||||||
{
|
{
|
||||||
@@ -71,8 +59,9 @@ EOT
|
|||||||
Mind::write('currentProjectRequiredTip');
|
Mind::write('currentProjectRequiredTip');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Mind::write('thinking');
|
||||||
if($exec= Mind::$gosh->generate(Array(
|
if($exec= Mind::$gosh->generate(Array(
|
||||||
$this->what,
|
$this->lobe,
|
||||||
$this->param,
|
$this->param,
|
||||||
$this->detail,
|
$this->detail,
|
||||||
$this->optional,
|
$this->optional,
|
||||||
@@ -81,11 +70,4 @@ EOT
|
|||||||
return false;
|
return false;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,43 +10,24 @@
|
|||||||
*/
|
*/
|
||||||
class Info extends MindCommand implements program
|
class Info extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('info')
|
->setCommandName('info')
|
||||||
->setDescription('Performs some tests on theWebMind')
|
->setDescription('Performs some tests on theWebMind')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
->setDefinition(array())
|
->setAction('action')
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
Executes specific tests and report their results, about the system itself
|
Executes specific tests and report their results, about the system itself
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
$this->init();
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
GLOBAL $_MIND;
|
GLOBAL $_MIND;
|
||||||
if(!parent::verifyCredentials())
|
|
||||||
return false;
|
|
||||||
print_r($_MIND->about);
|
print_r($_MIND->about);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,38 +5,24 @@
|
|||||||
|
|
||||||
class Quit extends MindCommand implements program
|
class Quit extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('exit')
|
$this->setCommandName('exit')
|
||||||
->setDescription('Finishes the application')
|
->setDescription('Finishes the application')
|
||||||
->setDefinition(Array())
|
->setAction('action')
|
||||||
|
->setRestrict(false)
|
||||||
->setFileName('Quit')
|
->setFileName('Quit')
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
Finishes the application, leaving the console;
|
Finishes the application, leaving the console;
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
$this->init();
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
$this->runAction();
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
{
|
||||||
$this->runAction();
|
@session_destroy();
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
|
||||||
session_destroy();
|
|
||||||
Mind::write('bye');
|
Mind::write('bye');
|
||||||
return $this;
|
exit;
|
||||||
}
|
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,94 +8,48 @@
|
|||||||
|
|
||||||
class RunTest extends MindCommand implements program
|
class RunTest extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public $unit=false;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this->setCommandName('test')
|
||||||
->setName('test')
|
->setDescription('Performs some tests on theWebMind')
|
||||||
->setDescription('Performs some tests on theWebMind')
|
->setRestrict(false)
|
||||||
->setRestrict(false)
|
->setAction('action')
|
||||||
->setDefinition(Array(
|
->setFileName('RunTest')
|
||||||
new InputOption('unit', '-u', InputOption::PARAMETER_NONE, 'Execute unit tests, also')
|
->setHelp(<<<EOT
|
||||||
))
|
Executes specific tests and report their results, about the system itself
|
||||||
->setFileName('RunTest')
|
|
||||||
->setHelp(<<<EOT
|
|
||||||
Executes specific tests and report their results, about the system itself
|
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->addFlag('unit', '-u', 'Also execute unit tests');
|
||||||
|
|
||||||
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function action()
|
public function action()
|
||||||
{
|
{
|
||||||
GLOBAL $_MIND;
|
GLOBAL $_MIND;
|
||||||
|
ob_start();
|
||||||
$this->runStep1();
|
$this->runStep1();
|
||||||
|
ob_flush();
|
||||||
$this->runStep2();
|
$this->runStep2();
|
||||||
|
ob_flush();
|
||||||
$this->runStep3();
|
$this->runStep3();
|
||||||
if($this->unitTestsAlso)
|
ob_flush();
|
||||||
|
|
||||||
|
if($this->unit)
|
||||||
{
|
{
|
||||||
if(file_exists(_MINDSRC_."/Tests/bundle.list"))
|
if(!isset($_MIND->conf['phpunit-src']))
|
||||||
{
|
{
|
||||||
if(!isset($_MIND->conf['phpunit-src']))
|
\Mind::write('phpunitNotFound');
|
||||||
{
|
return false;
|
||||||
// TODO: put it into speaker classes, to use l10n messages
|
}
|
||||||
echo " You must specify where to find phpUnit classes\n";
|
\Mind::write('runnintPHPUnit');
|
||||||
echo " You can configure it on mind3rd/env/mind.ini ini file\n";
|
ob_flush();
|
||||||
echo " changing the phpunit-src ini property\n";
|
echo shell_exec($_MIND->conf['phpunit-src']." "._MINDSRC_."/Tests/");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// TODO: it doesn't work yet
|
|
||||||
/*
|
|
||||||
$unitTestsFolder= _MINDSRC_."/Tests/";
|
|
||||||
$unitTestsList= file_get_contents($unitTestsFolder."bundle.list");
|
|
||||||
$unitTestsList= explode("\n", $unitTestsList);
|
|
||||||
|
|
||||||
foreach($unitTestsList as $unitTests)
|
|
||||||
{
|
|
||||||
$unitTests= explode(' ', $unitTests);
|
|
||||||
echo "Applying Unit tests to ".$unitTests[1]."\n";
|
|
||||||
//include_once $unitTestsFolder.$unitTests[0];
|
|
||||||
echo shell_exec("phpunit ".$unitTestsFolder.$unitTests[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
// TODO: send it to the speaker
|
|
||||||
echo "[Error] Unit Tests not fount in [root]/Tests\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$this->unitTestsAlso= $input->getOption('unit')? true: false;
|
|
||||||
|
|
||||||
return $this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$this->unitTestsAlso= (isset($_REQ['data'])
|
|
||||||
&&
|
|
||||||
isset($_REQ['data']['unit']))?
|
|
||||||
true: false;
|
|
||||||
|
|
||||||
return $this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function runStep1()
|
private function runStep1()
|
||||||
{
|
{
|
||||||
@@ -122,8 +76,4 @@ EOT
|
|||||||
$stat= '[OK]';
|
$stat= '[OK]';
|
||||||
Mind::message('Read & Write permissions', $stat);
|
Mind::message('Read & Write permissions', $stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($name = null) {
|
|
||||||
parent::__construct($name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,64 +12,30 @@
|
|||||||
*/
|
*/
|
||||||
class SetUse extends MindCommand implements program
|
class SetUse extends MindCommand implements program
|
||||||
{
|
{
|
||||||
private $argName= false;
|
public $projectName= false;
|
||||||
private $what= false;
|
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('use')
|
$this->setCommandName('use')
|
||||||
->setDescription('Opens the project, or specifies any personal option')
|
->setDescription('Opens the project, or specifies any personal option')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
|
->setaction('action')
|
||||||
->setFileName('SetUse')
|
->setFileName('SetUse')
|
||||||
->setDefinition(Array(
|
|
||||||
new InputArgument('what', InputArgument::REQUIRED, 'What to use, from now on'),
|
|
||||||
new InputArgument('name', InputArgument::REQUIRED, 'specify what you want to use/open')
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
You can use this command to start using a different language or project, for example
|
You can use this command to start using a different language or project, for example
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->addRequiredArgument('projectName', 'Specify the project name, you want to use/open');
|
||||||
|
|
||||||
|
$this->init();
|
||||||
}
|
}
|
||||||
public function execute(Console\Input\InputInterface $input,
|
|
||||||
Console\Output\OutputInterface $output)
|
public function action()
|
||||||
{
|
{
|
||||||
if(!parent::execute($input, $output))
|
if(!$projectData= Mind::hasProject($this->projectName))
|
||||||
return false;
|
return false;
|
||||||
$this->what= $input->getArgument('what');
|
Mind::openProject($projectData);
|
||||||
$this->argName= $input->getArgument('name');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
if(isset($_REQ['data']['what']) && isset($_REQ['data']['name']))
|
|
||||||
{
|
|
||||||
$this->argName= $_REQ['data']['name'];
|
|
||||||
$this->what= $_REQ['data']['what'];
|
|
||||||
}
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
|
||||||
switch($this->what)
|
|
||||||
{
|
|
||||||
case 'project':
|
|
||||||
if(!$projectData= Mind::hasProject($this->argName))
|
|
||||||
return false;
|
|
||||||
Mind::openProject($projectData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,56 +5,32 @@
|
|||||||
|
|
||||||
class Show extends MindCommand implements program
|
class Show extends MindCommand implements program
|
||||||
{
|
{
|
||||||
private $whatToShow= null;
|
public $what= null;
|
||||||
|
public $detailed= false;
|
||||||
|
public $extra= '';
|
||||||
|
|
||||||
public function configure()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->setName('show')
|
$this->setCommandName('show')
|
||||||
->setDescription('Show many different kind of data')
|
->setDescription('Show many different kind of data')
|
||||||
->setDefinition(array(
|
->setAction('action')
|
||||||
new InputArgument('what', InputArgument::REQUIRED, 'What to show'),
|
|
||||||
new InputOption('detailed', '-d', InputOption::PARAMETER_NONE, 'Show detailed data'),
|
|
||||||
new InputArgument('extra', InputArgument::OPTIONAL, 'Extra information to be used'),
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
You can use this command to see lists or details of a sort of components
|
You can use this command to see lists or details of a sort of components
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
$this->addRequiredArgument('what', 'What to how');
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
$this->addOptionalArgument('extra', 'Extra information to be used');
|
||||||
{
|
$this->addFlag('detailed', '-d', 'Show detailed data');
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
$this->init();
|
||||||
$this->whatToShow= $input->getArgument('what');
|
|
||||||
//echo $input->getOption('detailed')."\n";
|
|
||||||
$this->detailed= $input->getOption('detailed');
|
|
||||||
$this->extra= $input->getArgument('extra');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
$this->whatToShow= $_REQ['data']['what'];
|
|
||||||
if(isset($_REQ['data']['detailed']) && $_REQ['data']['detailed'])
|
|
||||||
$this->detailed= 1;
|
|
||||||
else
|
|
||||||
$this->detailed= false;
|
|
||||||
if(isset($_REQ['data']['extra']))
|
|
||||||
$this->extra= $_REQ['data']['extra'];
|
|
||||||
else
|
|
||||||
$this->extra= false;
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
GLOBAL $_REQ;
|
GLOBAL $_REQ;
|
||||||
GLOBAL $_MIND;
|
GLOBAL $_MIND;
|
||||||
switch($this->whatToShow)
|
switch($this->what)
|
||||||
{
|
{
|
||||||
case 'projects':
|
case 'projects':
|
||||||
$projs= $this->loadProjectList();
|
$projs= $this->loadProjectList();
|
||||||
@@ -153,20 +129,12 @@ EOT
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Mind::write('invalidOption', true, $this->whatToShow);
|
Mind::write('invalidOption', true, $this->what);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function loadProjectList()
|
private function loadProjectList()
|
||||||
{
|
{
|
||||||
$db= new MindDB();
|
$db= new MindDB();
|
||||||
@@ -222,4 +190,4 @@ EOT
|
|||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Symfony\Component\Console\Input\InputArgument,
|
|
||||||
Symfony\Component\Console\Input\InputOption,
|
|
||||||
Symfony\Component\Console;
|
|
||||||
|
|
||||||
class CommandName extends MindCommand implements program
|
|
||||||
{
|
|
||||||
public function configure()
|
|
||||||
{
|
|
||||||
$this->setName('Mind:commandName')
|
|
||||||
->setDescription('CommandDescription')
|
|
||||||
->setDefinition(array(
|
|
||||||
new InputArgument('arg1', InputArgument::REQUIRED, 'ArgDescription.'),
|
|
||||||
new InputOption(
|
|
||||||
'Option', null, InputOption::PARAMETER_REQUIRED,
|
|
||||||
'Description of the option',
|
|
||||||
'object'
|
|
||||||
),
|
|
||||||
new InputOption('detailed', '-d', InputOption::PARAMETER_NONE, ''),
|
|
||||||
new InputOption(
|
|
||||||
'first-result', null, InputOption::PARAMETER_REQUIRED,
|
|
||||||
'The first result in the result set.'
|
|
||||||
)
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
|
||||||
Executes arbitrary DQL directly from the command line.
|
|
||||||
EOT
|
|
||||||
);
|
|
||||||
}
|
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
|
||||||
{
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HTTPExecute()
|
|
||||||
{
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
// this is used to run the plugins set to be executed
|
|
||||||
// AFTER the execution of the current program
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,54 +10,38 @@
|
|||||||
*/
|
*/
|
||||||
class DQB extends MindCommand implements program
|
class DQB extends MindCommand implements program
|
||||||
{
|
{
|
||||||
public function configure()
|
public $query=null;
|
||||||
|
public $table=null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('dqb')
|
->setCommandName('dqb')
|
||||||
->setDescription('Performs some tests on theWebMind')
|
->setDescription('Performs some tests on theWebMind')
|
||||||
->setRestrict(true)
|
->setRestrict(true)
|
||||||
->setDefinition(array(
|
->setAction('action')
|
||||||
new InputArgument('query',
|
|
||||||
InputArgument::REQUIRED,
|
|
||||||
'Options: create, drop, alter, insert, delete, select and update'),
|
|
||||||
new InputArgument('table',
|
|
||||||
InputArgument::REQUIRED,
|
|
||||||
"Which table will have its query built. Use * to see them all."),
|
|
||||||
))
|
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
This program will create the needed query to the selected database.
|
This program will create the needed query to the selected database.
|
||||||
Notice that it will NOT execute then, only return them as a string.
|
Notice that it will NOT execute then, only return them as a string.
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
|
||||||
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
|
//$this->addRequiredArgument('query', 'Options: create, drop, alter, insert, delete, select and update');
|
||||||
{
|
$this->addRequiredArgument('table', 'Which table will have its query built. Use * to see them all.');
|
||||||
if(!parent::execute($input, $output))
|
|
||||||
return false;
|
$this->init();
|
||||||
$this->query= $input->getArgument('query');
|
|
||||||
$this->table= $input->getArgument('table');
|
|
||||||
$this->runAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HTTPExecute()
|
public function action()
|
||||||
{
|
|
||||||
GLOBAL $_REQ;
|
|
||||||
if(!parent::HTTPExecute())
|
|
||||||
return false;
|
|
||||||
if(isset($_REQ['data']['query']) && isset($_REQ['data']['table']))
|
|
||||||
{
|
|
||||||
$this->query= $_REQ['data']['query'];
|
|
||||||
$this->table= $_REQ['data']['table'];
|
|
||||||
}
|
|
||||||
$this->runAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function action()
|
|
||||||
{
|
{
|
||||||
GLOBAL $_MIND, $_REQ;
|
GLOBAL $_MIND, $_REQ;
|
||||||
if(!parent::verifyCredentials())
|
if(!parent::verifyCredentials())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// for now, only the create has been developed
|
||||||
|
// even if the following options are already described there are not
|
||||||
|
// plans to build them so soon.
|
||||||
|
$this->query= 'c';
|
||||||
switch($this->query)
|
switch($this->query)
|
||||||
{
|
{
|
||||||
case 'create':
|
case 'create':
|
||||||
@@ -90,11 +74,4 @@ EOT
|
|||||||
echo $qrs;
|
echo $qrs;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runAction()
|
|
||||||
{
|
|
||||||
$ret= $this->action();
|
|
||||||
parent::runAction();
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,13 @@
|
|||||||
// in this example, we will simply show a message using one argument
|
// in this example, we will simply show a message using one argument
|
||||||
echo " This command has just been executed!\n";
|
echo " This command has just been executed!\n";
|
||||||
echo " With argument: ".$this->firstArgument."\n\n";
|
echo " With argument: ".$this->firstArgument."\n\n";
|
||||||
|
$this->prompt('name', "What's your name?");
|
||||||
|
echo "Hello ".$this->answers['name']."\n";
|
||||||
|
$this->prompt('pwd', 'Say a magic word!', true);
|
||||||
|
$this->prompt('genre', "\nwhat is your genre?",
|
||||||
|
Array('F'=>'Female',
|
||||||
|
'M'=>'Male'));
|
||||||
|
echo "\nOW, ok :)\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -45,7 +52,7 @@
|
|||||||
->setDescription("This is a model command, only")
|
->setDescription("This is a model command, only")
|
||||||
->setRestrict(false)
|
->setRestrict(false)
|
||||||
->setHelp("A longer text, explaining the command")
|
->setHelp("A longer text, explaining the command")
|
||||||
->setAction('executableFunction');
|
->setAction('executableFunction'); // in this case, the method MUST be public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||