From 3887f5746c1de896246aa7f66207ab2e7e7a5fad Mon Sep 17 00:00:00 2001 From: "Felipe N. Moura" Date: Sat, 7 Apr 2012 01:19:37 -0300 Subject: [PATCH] changes to the help commands and how to install or uninstall the application. Changes made on external(symfony) classes! To change the help format as needed Fixed some typing mistakes --- index.php | 1 + mind | 20 +++++++ mind3rd/API/L10N/en.php | 2 +- .../Symfony/Component/Console/Application.php | 10 ++-- .../Component/Console/Command/HelpCommand.php | 10 ++-- .../Symfony/Component/Console/Shell.php | 10 +++- mind3rd/API/programs/Create.php | 2 +- mind3rd/API/programs/Info.php | 2 +- mind3rd/API/programs/Install.php | 2 +- mind3rd/API/programs/Quit.php | 1 + mind3rd/API/programs/RunTest.php | 18 +++++++ mind3rd/API/programs/helpContent.php | 54 +++++++++++++++++++ mind3rd/API/shell.php | 12 +++-- mind3rd/env/setup/UnixSetup.php | 21 +++----- mind3rd/env/setup/WinSetup.php | 2 +- 15 files changed, 132 insertions(+), 35 deletions(-) create mode 100755 mind3rd/API/programs/helpContent.php diff --git a/index.php b/index.php index f27a98e..80e0bb8 100755 --- a/index.php +++ b/index.php @@ -9,6 +9,7 @@ $_REQ['request_method']= $_SERVER['REQUEST_METHOD']; $_REQ['env']= 'http'; define('_MINDSRC_', getcwd()); + switch($_REQ['request_method']) { case 'GET' : $_REQ['data']= $_GET; diff --git a/mind b/mind index 9a4bd9b..f7790dd 100755 --- a/mind +++ b/mind @@ -60,6 +60,26 @@ } break; } + case '--help': + case '-h': + case '?': + case 'help':{ + echo "theWebMind(or just mind):\n website: http://thewebmind.org\n Twitter: @thewebmind\n Docs: http://docs.thewebmind.org\n\n"; + "The list of startup commands:\n". + " install : installs the application itself\n". + " uninstall: uninstalls the application, but do NOT remove projects,\n". + " users or history\n". + " remove : installs the application AND REMOVE every data it may\n". + " have created, including ALL projects, history and users.\n". + " --help :\n"; + " -h :\n"; + " help :\n"; + " ? :\n"; + " Shows this help content.\n\n"; + echo "After installing, you can open the application by calling the 'mind' command anywhere.\n". + "You will also be able to send POST requisition to mind's server address sending the command you want to execute and its parameters.\n"; + exit; + } } } // if not installing, it should be redirected to mind3rd/API/shell.php diff --git a/mind3rd/API/L10N/en.php b/mind3rd/API/L10N/en.php index 421af77..c8889cb 100755 --- a/mind3rd/API/L10N/en.php +++ b/mind3rd/API/L10N/en.php @@ -37,7 +37,7 @@ class En implements l10n{ $this->messages['not_allowed_tip'] = "Try calling the command\n auth < login >\nA password will be required.\n"; $this->messages['no_such_file'] = Mind::message("\nMain: No such command '%s'", "[Fail]", false); $this->messages['auth_fail'] = Mind::message("\nAuth: Wrong user or password", "[Fail]", false); - $this->messages['bye'] = "Logging out...\n"; + $this->messages['bye'] = "Thank you! See you later!\nLogging out...\n"; $this->messages['thinking'] = "Please wait while I'm thinking...\n"; $this->messages['invalidCreateParams'] = Mind::message("Main: Invalid parameters", "[Fail]", false); $this->messages['invalidOption'] = Mind::message("Invalid option '%s'", '[Fail]', false); diff --git a/mind3rd/API/external/Symfony/Component/Console/Application.php b/mind3rd/API/external/Symfony/Component/Console/Application.php index af488e3..51c0bd8 100755 --- a/mind3rd/API/external/Symfony/Component/Console/Application.php +++ b/mind3rd/API/external/Symfony/Component/Console/Application.php @@ -61,6 +61,8 @@ class Application /** * Constructor. * + * CHANGED BY FELIPENMOURA + * * @param string $name The name of the application * @param string $version The version of the application */ @@ -84,11 +86,11 @@ class Application new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), new InputOption('--help', '-h', InputOption::PARAMETER_NONE, 'Display this help message.'), - new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'), - new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'), - new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'), + //new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'), + //new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'), + //new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'), new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'), - new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'), + //new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'), )); } diff --git a/mind3rd/API/external/Symfony/Component/Console/Command/HelpCommand.php b/mind3rd/API/external/Symfony/Component/Console/Command/HelpCommand.php index 3e93be6..6d4673c 100755 --- a/mind3rd/API/external/Symfony/Component/Console/Command/HelpCommand.php +++ b/mind3rd/API/external/Symfony/Component/Console/Command/HelpCommand.php @@ -45,13 +45,9 @@ class HelpCommand extends Command ->setAliases(array('?')) ->setDescription('Displays help for a command') ->setHelp(<<help command displays help for a given command: - - ./symfony help test:all - -You can also output the help as XML by using the --xml option: - - ./symfony help --xml test:all +The help command displays help for a given command. + Use the comand list to see the list of commands. + Use command --help to see details about each command. EOF ); } diff --git a/mind3rd/API/external/Symfony/Component/Console/Shell.php b/mind3rd/API/external/Symfony/Component/Console/Shell.php index a819428..1b65fce 100755 --- a/mind3rd/API/external/Symfony/Component/Console/Shell.php +++ b/mind3rd/API/external/Symfony/Component/Console/Shell.php @@ -66,7 +66,15 @@ class Shell while (true) { $command = readline($this->application->getName().' > '); - + + /** changed by felipeNMoura **/ + if($command == "\n" || $command == ""){ + $this->output->write(""); + continue; + } + /** end of changes made by felipnmoura **/ + + if (false === $command) { $this->output->writeln("\n"); diff --git a/mind3rd/API/programs/Create.php b/mind3rd/API/programs/Create.php index 09057d8..e1bcda8 100755 --- a/mind3rd/API/programs/Create.php +++ b/mind3rd/API/programs/Create.php @@ -31,7 +31,7 @@ class Create extends MindCommand implements program ->setAction('action') ->setHelp(<<setCommandName('info') - ->setDescription('Performs some tests on theWebMind') + ->setDescription('Shows some information about this instalation') ->setRestrict(true) ->setAction('action') ->setHelp(<<setCommandName('install') - ->setDescription("This program will be able to install components to the application.") + ->setDescription("Adds components to the application") //->setFileName('modeloTeste') // use this if your class has NOT the same name as its file ->setRestrict(true) ->setAdminAccess() diff --git a/mind3rd/API/programs/Quit.php b/mind3rd/API/programs/Quit.php index f3b630e..86372f9 100755 --- a/mind3rd/API/programs/Quit.php +++ b/mind3rd/API/programs/Quit.php @@ -28,6 +28,7 @@ EOT public function action() { @session_destroy(); + //\API\Program::execute('clear'); Mind::write('bye'); exit; } diff --git a/mind3rd/API/programs/RunTest.php b/mind3rd/API/programs/RunTest.php index 4cb354f..aee5402 100755 --- a/mind3rd/API/programs/RunTest.php +++ b/mind3rd/API/programs/RunTest.php @@ -34,6 +34,19 @@ EOT public function action() { GLOBAL $_MIND; + /*\API\Program::execute('clear'); + echo "|==> |"; + sleep(1); + \API\Program::execute('clear'); + echo "|========> |"; + sleep(1); + \API\Program::execute('clear'); + echo "|===============> |"; + sleep(1); + \API\Program::execute('clear'); + echo "|=========================>|\n"; + sleep(1);*/ + ob_start(); $this->runStep1(); @@ -55,6 +68,11 @@ EOT echo shell_exec($_MIND->conf['phpunit-src']." "._MINDSRC_."/Tests/"); } ob_end_flush(); + + // gotoxy + // printf("\033[2;10f"); + + return true; } diff --git a/mind3rd/API/programs/helpContent.php b/mind3rd/API/programs/helpContent.php new file mode 100755 index 0000000..2f62d6c --- /dev/null +++ b/mind3rd/API/programs/helpContent.php @@ -0,0 +1,54 @@ + + * @license licenses/mind3rd.license + */ + use Symfony\Component\Console\Input\InputArgument, + Symfony\Component\Console\Input\InputOption, + Symfony\Component\Console; + + /** + * This class represents a model for programs + * + * @author Felipe Nascimento de Moura + */ + class helpContent extends MindCommand implements program + { + + public function executableFunction() + { + echo "theWebMind(or just mind):\n website: http://thewebmind.org\n Twitter: @thewebmind\n Docs: http://docs.thewebmind.org\n\n"; + "The list of startup commands:\n". + " install : installs the application itself\n". + " uninstall: uninstalls the application, but do NOT remove projects,\n". + " users or history\n". + " remove : installs the application AND REMOVE every data it may\n". + " have created, including ALL projects, history and users.\n". + " --help :\n"; + " -h :\n"; + " help :\n"; + " ? :\n"; + " Shows this help content.\n\n"; + echo "After installing, you can open the application by calling the 'mind' command anywhere.\n". + "You will also be able to send POST requisition to mind's server address sending the command you want to execute and its parameters.\n"; + } + + public function __construct() + { + $this->setCommandName('helps') + ->setFileName('helpContent') + ->setDescription("Shows the help content") + ->setRestrict(false) + ->setHelp("Shows the help content") + ->setAction(function($class){ + $class->executableFunction(); + }); + + /*$this->addRequiredArgument('firstArgument', + 'first, and required argument', + Array('X', 'Y', 'Z'));*/ + $this->init(); + } + } \ No newline at end of file diff --git a/mind3rd/API/shell.php b/mind3rd/API/shell.php index 4c90fb0..09d8655 100755 --- a/mind3rd/API/shell.php +++ b/mind3rd/API/shell.php @@ -7,9 +7,9 @@ */ // setting the general helperSet - $helperSet= false; - $helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet(); - $app->setHelperSet($helperSet); + $helperSet= true; + /*$helperSet= ($helperSet) ?: new Symfony\Component\Console\Helper\HelperSet(); + $app->setHelperSet($helperSet);*/ if(isset($_SERVER['argv'])) { @@ -21,6 +21,8 @@ /* let's load the plugins, if they are allowed */ Mind::$triggers= array_keys($app->getCommands()); + //var_dump($app); + try { $sh= new Symfony\Component\Console\Shell($app); $sh->run(); @@ -34,6 +36,6 @@ } else echo " Please, follow these instructions to install it: http://goo.gl/UDrEY\n\n"; - echo " NOTE: Even without the readline extension, you already can use the\n"; - echo " system via HTTP once it does not need the shell to work\n\n"; + echo " NOTE: Even without the readline extension, you already can use the\n"; + echo " system via HTTP once it does not need the shell to work\n\n"; } \ No newline at end of file diff --git a/mind3rd/env/setup/UnixSetup.php b/mind3rd/env/setup/UnixSetup.php index e7fb84f..47bd3b8 100755 --- a/mind3rd/env/setup/UnixSetup.php +++ b/mind3rd/env/setup/UnixSetup.php @@ -22,23 +22,18 @@ class UnixSetup extends Setup{ */ public static function createExecFile() { - /* - $uriToAdd= getcwd()."/"; - //echo $uriToAdd."
"; - ///usr/local/bin:/usr/bin:/bin - //echo shell_exec('echo $PATH'); - echo "
"; - echo getenv('PATH').PATH_SEPARATOR.$uriToAdd; - echo "
"; - echo shell_exec('expert PATH=$PATH'.PATH_SEPARATOR.$uriToAdd); - echo shell_exec('echo $PATH'); - echo "
"; - */ self::$content= '0 && isset($_SERVER["argv"][1])){ + require("'.getcwd().'/mind"); + }else{ + require("'.getcwd().'/mind3rd/API/utils/utils.php"); + } +'; echo " starting the installation...\n"; echo " creating the file...\n"; diff --git a/mind3rd/env/setup/WinSetup.php b/mind3rd/env/setup/WinSetup.php index deeb014..385bcc0 100755 --- a/mind3rd/env/setup/WinSetup.php +++ b/mind3rd/env/setup/WinSetup.php @@ -28,7 +28,7 @@ abstract class WinSetup extends Setup{ * for readline on windows! Then, on windows, the system will run * ONLY with HTTP requisitions...sorry guys! */ - // + // /* $runDir= str_replace('cmd.exe', '', getenv('COMSPEC')); $phpBin= '';