<commit_before><?php
namespace Samurai\Module\Task\Factory;

use Pimple\Container;
use Samurai\Module\Task\Enabling;
use Samurai\Module\Task\Listing;
use Samurai\Module\Task\Removing;
use Samurai\Module\Task\Running;
use Samurai\Module\Task\Saving;
use Samurai\Task\ITask;
use SimilarText\Finder;
use Symfony\Component\Console\Input\InputInterface;

/**
 * Class TaskFactory
 * @package Samurai\Alias\Task\Factory
 * @author <NAME> <<EMAIL>>
 */
class ModuleManagementTaskFactory
{
    /**
     * @param InputInterface $input
     * @param Container $services
     * @return ITask
     */
    public static function create(InputInterface $input, Container $services)
    {
        if($input->getArgument('action') === 'list'){
            return new Listing($services);
        }
        if($input->getArgument('action') === 'save'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            if(!$input->getArgument('package')){
                throw new \InvalidArgumentException('package param is mandatory for this action');
            }
            return new Saving($services);
        }
        if($input->getArgument('action') === 'rm' || $input->getArgument('action') === 'remove'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            return new Removing($services);
        }
        if($input->getArgument('action') === 'enable'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            throw new \RuntimeException('sorry, not yet set'); //todo
        }
        if($input->getArgument('action') === 'disable'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            throw new \RuntimeException('sorry, not yet set'); //todo
        }
        if($input->getArgument('action') === 'run' || !$input->getArgument('action')){
            return new Running($services);
        }

        $textFinder = new Finder($input->getArgument('action'), ['save', 'remove', 'rm', 'list', 'enable', 'disable', 'run']);
        throw new \InvalidArgumentException(sprintf(
            'Action "%s" not supported. Did you mean "%s"?',
            $input->getArgument('action'),
            $textFinder->first()
        ));
    }
}
<commit_msg>add Enabling to the module action<commit_after><?php
namespace Samurai\Module\Task\Factory;

use Pimple\Container;
use Samurai\Module\Task\Enabling;
use Samurai\Module\Task\Listing;
use Samurai\Module\Task\Removing;
use Samurai\Module\Task\Running;
use Samurai\Module\Task\Saving;
use Samurai\Task\ITask;
use SimilarText\Finder;
use Symfony\Component\Console\Input\InputInterface;

/**
 * Class TaskFactory
 * @package Samurai\Alias\Task\Factory
 * @author <NAME> <<EMAIL>>
 */
class ModuleManagementTaskFactory
{
    /**
     * @param InputInterface $input
     * @param Container $services
     * @return ITask
     */
    public static function create(InputInterface $input, Container $services)
    {
        if($input->getArgument('action') === 'list'){
            return new Listing($services);
        }
        if($input->getArgument('action') === 'save'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            if(!$input->getArgument('package')){
                throw new \InvalidArgumentException('package param is mandatory for this action');
            }
            return new Saving($services);
        }
        if($input->getArgument('action') === 'rm' || $input->getArgument('action') === 'remove'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            return new Removing($services);
        }
        if($input->getArgument('action') === 'enable'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            return new Enabling($services);
        }
        if($input->getArgument('action') === 'disable'){
            if(!$input->getArgument('name')){
                throw new \InvalidArgumentException('name param is mandatory for this action');
            }
            return new Enabling($services);
        }
        if($input->getArgument('action') === 'run' || !$input->getArgument('action')){
            return new Running($services);
        }

        $textFinder = new Finder($input->getArgument('action'), ['save', 'remove', 'rm', 'list', 'enable', 'disable', 'run']);
        throw new \InvalidArgumentException(sprintf(
            'Action "%s" not supported. Did you mean "%s"?',
            $input->getArgument('action'),
            $textFinder->first()
        ));
    }
}

{'fraction_non_alphanumeric': 0.1501361338000778, 'fraction_numerical': 0.0, 'mean_word_length': 2.5517955801104972, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, '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': '5404826', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1334, 'n_words': 315}