<commit_before><?php

namespace Nova\Foundation\Console;

use Nova\Console\Command;
use Nova\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;


class CommandMakeCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'command:make';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = "Create a new Forge command";

    /**
     * Create a new command creator command.
     *
     * @param  \Nova\Filesystem\Filesystem  $files
     * @return void
     */
    public function __construct(Filesystem $files)
    {
        parent::__construct();

        $this->files = $files;
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        $path = $this->getPath();

        $stub = $this->files->get(__DIR__.'/stubs/command.stub');

        // We'll grab the class name to determine the file name. Since applications are
        // typically using the PSR-0 standards we can safely assume the classes name
        // will correspond to what the actual file should be stored as on storage.
        $file = $path.'/'.$this->input->getArgument('name').'.php';

        $this->writeCommand($file, $stub);
    }

    /**
     * Write the finished command file to disk.
     *
     * @param  string  $file
     * @param  string  $stub
     * @return void
     */
    protected function writeCommand($file, $stub)
    {
        if ( ! file_exists($file)) {
            $this->files->put($file, $this->formatStub($stub));

            $this->info('Command created successfully.');
        } else {
            $this->error('Command already exists!');
        }
    }

    /**
     * Format the command class stub.
     *
     * @param  string  $stub
     * @return string
     */
    protected function formatStub($stub)
    {
        $stub = str_replace('{{class}}', $this->input->getArgument('name'), $stub);

        if ( ! is_null($this->option('command'))) {
            $stub = str_replace('command:name', $this->option('command'), $stub);
        }

        return $this->addNamespace($stub);
    }

    /**
     * Add the proper namespace to the command.
     *
     * @param  string  $stub
     * @return string
     */
    protected function addNamespace($stub)
    {
        if ( ! is_null($namespace = $this->input->getOption('namespace'))) {
            return str_replace('{{namespace}}', ' namespace App\Commands\\'.$namespace.';', $stub);
        } else {
            return str_replace('{{namespace}}', ' namespace App\Commands;', $stub);
        }
    }

    /**
     * Get the path where the command should be stored.
     *
     * @return string
     */
    protected function getPath()
    {
        $path = $this->input->getOption('path');

        if (is_null($path)) {
            return $this->framework['path'] .'/Commands';
        } else {
            return $this->framework['path.base'] .DS .$path;
        }
    }

    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return array(
            array('name', InputArgument::REQUIRED, 'The name of the command.'),
        );
    }
<commit_msg>Store the generated Forge commands on app/Console<commit_after><?php

namespace Nova\Foundation\Console;

use Nova\Console\Command;
use Nova\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;


class CommandMakeCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'command:make';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = "Create a new Forge command";

    /**
     * Create a new command creator command.
     *
     * @param  \Nova\Filesystem\Filesystem  $files
     * @return void
     */
    public function __construct(Filesystem $files)
    {
        parent::__construct();

        $this->files = $files;
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        $path = $this->getPath();

        $stub = $this->files->get(__DIR__.'/stubs/command.stub');

        // We'll grab the class name to determine the file name. Since applications are
        // typically using the PSR-0 standards we can safely assume the classes name
        // will correspond to what the actual file should be stored as on storage.
        $file = $path.'/'.$this->input->getArgument('name').'.php';

        $this->writeCommand($file, $stub);
    }

    /**
     * Write the finished command file to disk.
     *
     * @param  string  $file
     * @param  string  $stub
     * @return void
     */
    protected function writeCommand($file, $stub)
    {
        if ( ! file_exists($file)) {
            $this->files->put($file, $this->formatStub($stub));

            $this->info('Command created successfully.');
        } else {
            $this->error('Command already exists!');
        }
    }

    /**
     * Format the command class stub.
     *
     * @param  string  $stub
     * @return string
     */
    protected function formatStub($stub)
    {
        $stub = str_replace('{{class}}', $this->input->getArgument('name'), $stub);

        if ( ! is_null($this->option('command'))) {
            $stub = str_replace('command:name', $this->option('command'), $stub);
        }

        return $this->addNamespace($stub);
    }

    /**
     * Add the proper namespace to the command.
     *
     * @param  string  $stub
     * @return string
     */
    protected function addNamespace($stub)
    {
        if ( ! is_null($namespace = $this->input->getOption('namespace'))) {
            return str_replace('{{namespace}}', ' namespace App\Console\\'.$namespace.';', $stub);
        } else {
            return str_replace('{{namespace}}', ' namespace App\Console;', $stub);
        }
    }

    /**
     * Get the path where the command should be stored.
     *
     * @return string
     */
    protected function getPath()
    {
        $path = $this->input->getOption('path');

        if (is_null($path)) {
            return $this->framework['path'] .'/Console';
        } else {
            return $this->framework['path.base'] .DS .$path;
        }
    }

    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return array(
            array('name', InputArgument::REQUIRED, 'The name of the command.'),
        );
    }

{'fraction_non_alphanumeric': 0.14188489421512057, 'fraction_numerical': 0.00029590176061547566, 'mean_word_length': 2.036837376460018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '1075940', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1936, 'n_words': 484}