Adding some programs

Esse commit está contido em:
Felipe
2010-10-31 22:50:15 -02:00
commit 581435588d
11 arquivos alterados com 360 adições e 0 exclusões
+71
Ver Arquivo
@@ -0,0 +1,71 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Auth extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('auth')
->setDescription('Autenticate a user')
->setDefinition(Array(
new InputArgument('login', InputArgument::REQUIRED, 'Login to access')
))
->setHelp(<<<EOT
Sets the user with a password.
It is required to run most of the commands
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
Mind::write('passwordRequired', true);
$pw= $this->getPassword(true);
Mind::write('autenticated', true, $input->getArgument('login'));
Mind::write("xxxxxx");
//echo "\n[OK] ".$input->getArgument('login')." ".Mind::write('autenticated')."\n";
}
/**
* function taken from: http://www.dasprids.de/blog/2008/08/22/getting-a-password-hidden-from-stdin-with-php-cli
* this method should read the user's password not showing any character of their password
* @param Booladn $stars if true, show an * for each typed char
* @return String password
*/
private function getPassword($stars = false)
{
// Get current style
$oldStyle = shell_exec('stty -g');
if ($stars === false) {
shell_exec('stty -echo');
$password = rtrim(fgets(STDIN), "\n");
} else {
shell_exec('stty -icanon -echo min 1 time 0');
$password = '';
while (true) {
$char = fgetc(STDIN);
if ($char === "\n") {
break;
} else if (ord($char) === 127) {
if (strlen($password) > 0) {
fwrite(STDOUT, "\x08 \x08");
$password = substr($password, 0, -1);
}
} else {
fwrite(STDOUT, "*");
$password .= $char;
}
}
}
// Reset old style
shell_exec('stty ' . $oldStyle);
// Return the password
return $password;
}
}
+68
Ver Arquivo
@@ -0,0 +1,68 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Auth extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('auth')
->setDescription('Autenticate a user')
->setDefinition(Array(
new InputArgument('login', InputArgument::REQUIRED, 'Login to access')
))
->setHelp(<<<EOT
Sets the user with a password.
It is required to run most of the commands
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$pw= $this->getPassword(true);
echo "\n[OK] ".$input->getArgument('login')." autenticated\n";
}
/**
* function taken from: http://www.dasprids.de/blog/2008/08/22/getting-a-password-hidden-from-stdin-with-php-cli
* this method should read the user's password not showing any character of their password
* @param Booladn $stars if true, show an * for each typed char
* @return String password
*/
private function getPassword($stars = false)
{
// Get current style
$oldStyle = shell_exec('stty -g');
if ($stars === false) {
shell_exec('stty -echo');
$password = rtrim(fgets(STDIN), "\n");
} else {
shell_exec('stty -icanon -echo min 1 time 0');
$password = '';
while (true) {
$char = fgetc(STDIN);
if ($char === "\n") {
break;
} else if (ord($char) === 127) {
if (strlen($password) > 0) {
fwrite(STDOUT, "\x08 \x08");
$password = substr($password, 0, -1);
}
} else {
fwrite(STDOUT, "*");
$password .= $char;
}
}
}
// Reset old style
shell_exec('stty ' . $oldStyle);
// Return the password
return $password;
}
}
+22
Ver Arquivo
@@ -0,0 +1,22 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Clear extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('clear')
->setDescription('Clears the console')
->setDefinition(array())
->setHelp(<<<EOT
Clears the console
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
system('clear');
}
}
+22
Ver Arquivo
@@ -0,0 +1,22 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Quit extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('Mind:exit')
->setDescription('Finishes the application')
->setDefinition(null)
->setHelp(<<<EOT
Finishes the application, leaving the console;
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
//exit;
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Quit extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('exit')
->setDescription('Finishes the application')
->setDefinition(Array())
->setHelp(<<<EOT
Finishes the application, leaving the console;
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
echo "Logging out...\n";
exit;
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class Quit extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this->setName('quit')
->setDescription('Finishes the application')
->setDefinition(Array())
->setHelp(<<<EOT
Finishes the application, leaving the console;
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
echo "Logging out...\n";
exit;
}
}
+37
Ver Arquivo
@@ -0,0 +1,37 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class RunTest extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this
->setName('test')
->setDescription('Performs some tests on theWebMind')
->setDefinition(array())
->setHelp(<<<EOT
Executes specific tests and report their results, about the system itself
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
if(!isset($_SESSION['auth']))
{
Mind::write('not_allowed');
Mind::write('not_allowed_tip');
return false;
}
$this->runStep1();
}
private function runStep1()
{
Mind::message('Autoloader', '[OK]');
Mind::message('Includes', '[OK]');
return true;
}
}
+30
Ver Arquivo
@@ -0,0 +1,30 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class RunTest extends Symfony\Component\Console\Command\Command
{
public function configure()
{
$this
->setName('test')
->setDescription('Executes arbitrary DQL directly from the command line.')
->setDefinition(array())
->setHelp(<<<EOT
Executes arbitrary DQL directly from the command line.
EOT
);
}
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$this->runStep1();
}
private function runStep1()
{
Mind::message('Autoloader', '[OK]');
return true;
}
}
Arquivo normal → Arquivo executável
Ver Arquivo
+32
Ver Arquivo
@@ -0,0 +1,32 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class CommandName extends Symfony\Component\Console\Command\Command
{
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(
'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)
{
}
}
+32
Ver Arquivo
@@ -0,0 +1,32 @@
<?php
use Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console;
class CommandName extends Symfony\Component\Console\Command\Command
{
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(
'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)
{
}
}