<commit_before><?php
/**
 *  AddAction.php
 *
 *  @author     <NAME> <<EMAIL>>
 */
namespace Ethnam\Generator\Subcommand;

/**
 *  add-action handler
 *
 *  @author     <NAME> <<EMAIL>>
 *  @access     public
 */
class AddAction extends Base
{
    /**
     */
    public function perform()
    {
        //
        //  '-w[with-unittest]' and '-u[unittestskel]' option
        //  are not intuisive, but I dare to define them because
        //  -t and -s option are reserved by add-[action|view] handle
        //  and Ethna_Getopt cannot interpret two-character option.
        //
        $r = $this->_getopt(
                  array('basedir=',
                        'skelfile=',
                        'gateway=',
                        'with-unittest',
                        'unittestskel=',
                  )
             );

        list($opt_list, $arg_list) = $r;

        // action_name
        $action_name = array_shift($arg_list);
        if ($action_name == null) {
            throw new \Exception('action name isn\'t set.');
        }
        Base::checkActionName($action_name);

        $ret = $this->_perform('Action', $action_name, $opt_list);
        return $ret;
    }

    /**
     */
    private function _perform($target, $target_name, $opt_list)
    {
        // basedir
        if (isset($opt_list['basedir'])) {
            $basedir = realpath(end($opt_list['basedir']));
        } else {
            $basedir = getcwd();
        }

        // skelfile
        if (isset($opt_list['skelfile'])) {
            $skelfile = end($opt_list['skelfile']);
        } else {
            $skelfile = null;<commit_msg>_perform is called from the child class AddEntryPoint<commit_after><?php
/**
 *  AddAction.php
 *
 *  @author     <NAME> <<EMAIL>>
 */
namespace Ethnam\Generator\Subcommand;

/**
 *  add-action handler
 *
 *  @author     <NAME> <<EMAIL>>
 *  @access     public
 */
class AddAction extends Base
{
    /**
     */
    public function perform()
    {
        //
        //  '-w[with-unittest]' and '-u[unittestskel]' option
        //  are not intuisive, but I dare to define them because
        //  -t and -s option are reserved by add-[action|view] handle
        //  and Ethna_Getopt cannot interpret two-character option.
        //
        $r = $this->_getopt(
                  array('basedir=',
                        'skelfile=',
                        'gateway=',
                        'with-unittest',
                        'unittestskel=',
                  )
             );

        list($opt_list, $arg_list) = $r;

        // action_name
        $action_name = array_shift($arg_list);
        if ($action_name == null) {
            throw new \Exception('action name isn\'t set.');
        }
        Base::checkActionName($action_name);

        $ret = $this->_perform('Action', $action_name, $opt_list);
        return $ret;
    }

    /**
     */
    protected function _perform($target, $target_name, $opt_list)
    {
        // basedir
        if (isset($opt_list['basedir'])) {
            $basedir = realpath(end($opt_list['basedir']));
        } else {
            $basedir = getcwd();
        }

        // skelfile
        if (isset($opt_list['skelfile'])) {
            $skelfile = end($opt_list['skelfile']);
        } else {
            $skelfile = null;
{'fraction_non_alphanumeric': 0.14423076923076922, 'fraction_numerical': 0.0, 'mean_word_length': 1.5607692307692307, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '2734421', 'n_tokens_mistral': 1011, 'n_tokens_neox': 985, 'n_words': 208}