<commit_before><?php

/**
 * Created by PhpStorm.
 * User: pjedwabny
 * Date: 08.09.15
 * Time: 21:10
 */
namespace Epesi\Console\Modules;
use DB;
use ModuleManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UninstallModuleCommand extends Command
{
    protected function configure(){
        $this
            ->setName('module:uninstall')
            ->setDescription('Uninstall EPESI module')
            ->addArgument(
                'name',
                InputArgument::REQUIRED,
                'Module name'
            )
        ;
    }
    protected function execute(InputInterface $input, OutputInterface $output) {
        $module_name = $input->getArgument('name');
        $module = DB::GetRow("SELECT * FROM available_modules WHERE name = %s",$module_name);
        if(!$module)
            throw new \Exception('Module not found');

        if (!ModuleManager::is_installed($module['name'])) {
            $output->writeln('<fg=yellow>Module ' . $module_name . ' already installed</fg=yellow>');
            return;
        }

        if (ModuleManager::uninstall($module['name'])) {
            $output->writeln('<fg=green>Module ' . $module_name . ' installed</fg=green>');
        } else {
            $output->writeln('<fg=red>Module ' . $module_name . ' installing error</fg=red>');
        }
    }
}<commit_msg>[FIX] console uninstall module method<commit_after><?php

/**
 * Created by PhpStorm.
 * User: pjedwabny
 * Date: 08.09.15
 * Time: 21:10
 */
namespace Epesi\Console\Modules;
use DB;
use ModuleManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UninstallModuleCommand extends Command
{
    protected function configure(){
        $this
            ->setName('module:uninstall')
            ->setDescription('Uninstall EPESI module')
            ->addArgument(
                'name',
                InputArgument::REQUIRED,
                'Module name'
            )
        ;
    }
    protected function execute(InputInterface $input, OutputInterface $output) {
        $module_name = $input->getArgument('name');
        $module = DB::GetRow("SELECT * FROM available_modules WHERE name = %s",$module_name);
        if(!$module)
            throw new \Exception('Module not found');

        if (ModuleManager::is_installed($module['name']) < 0) {
            $output->writeln('<fg=yellow>Module ' . $module_name . ' not installed</fg=yellow>');
            return;
        }

        if (ModuleManager::uninstall($module['name'])) {
            $output->writeln('<fg=green>Module ' . $module_name . ' installed</fg=green>');
        } else {
            $output->writeln('<fg=red>Module ' . $module_name . ' installing error</fg=red>');
        }
    }
}
{'fraction_non_alphanumeric': 0.13922797756516, 'fraction_numerical': 0.006928406466512702, 'mean_word_length': 2.6311377245508982, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4759687', 'n_tokens_mistral': 874, 'n_tokens_neox': 844, 'n_words': 163}