<commit_before><?php

namespace Neutrino\Cli;

/**
 * Class Router
 *
 *  @package Neutrino\Cli
 */
class Router extends \Phalcon\Cli\Router
{
    /**
     * Adds a route to the router, with task as class.
     *
     * ex : $router->addTask('some', SomeTask::class);
     *
     * @param string      $pattern
     * @param string      $class
     * @param string|null $action
     * @param array       $params
     *
     * @return \Phalcon\Cli\Router\Route
     */
    public function addTask($pattern, $class, $action = null, array $params = [])
    {
        $params['task'] = $class;

        $params['action'] = $action;

        preg_match_all('/:([\w_]+):/', $pattern, $matches);

        foreach ($matches[0] as $k => $match) {
            $pattern = str_replace($match, '([[:alnum:]]+)', $pattern);

            $params[str_replace(':', '', $match)] = $k + 1;
        }

        return $this->add($pattern, $params);
    }
}
<commit_msg>feat(Cli\Router): Router::addTask change $pattern by $command. Use "my:cmd {arg}" for declaration insteadof regex.<commit_after><?php

namespace Neutrino\Cli;

/**
 * Class Router
 *
 *  @package Neutrino\Cli
 */
class Router extends \Phalcon\Cli\Router
{
    /**
     * Adds a route to the router, with task as class.
     *
     * ex : $router->addTask('some', SomeTask::class);
     *
     * @param string      $command
     * @param string      $class
     * @param string|null $action
     * @param array       $params
     *
     * @return \Phalcon\Cli\Router\Route|\Phalcon\Cli\Router\RouteInterface
     */
    public function addTask($command, $class, $action = null, array $params = [])
    {
        $params['task'] = $class;

        $params['action'] = $action;

        preg_match_all('/\{([\w_]+)\}/', $command, $matches);

        foreach ($matches[0] as $k => $match) {
            $command = str_replace($match, '([[:alnum:]]+)', $command);

            $params[str_replace(':', '', $match)] = $k + 1;
        }

        return $this->add($command, $params);
    }
}

{'fraction_non_alphanumeric': 0.18011811023622049, 'fraction_numerical': 0.001968503937007874, 'mean_word_length': 2.34375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6617014', 'n_tokens_mistral': 687, 'n_tokens_neox': 662, 'n_words': 150}