<?php 
namespace Sargilla\FlatLab\Console;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;

/**
 * Class Publish FlatLab.
 */
class PublishFlatLab extends Command
{
    use Installable;
    /**
     * The filesystem instance.
     *
     * @var \Illuminate\Filesystem\Filesystem
     */
    protected $files;

    /**
     * The name and signature of the console command.
     */
    protected $signature = 'flatlab:publish {--f|force : Force overwrite of files}';    

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Publicar Archivos de FlatLab para sobreescribir en un proyecto laravel';

    /**
     * Force overwrite of files.
     *
     * @var bool
     */
    protected $force = false;

    /**
     * Create a new command instance.
     *
     * @param \Illuminate\Filesystem\Filesystem $files
     *
     */
    public function __construct(Filesystem $files)
    {
        parent::__construct();
        $this->files = $files;
    }

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->processOptions();
        $this->publishLanguages();
        $this->publishConfig();
        $this->publishViews();
        $this->publishGravatar();
    }

    /**
     * Install FlatLab Language assets.
     */
    private function publishLanguages()
    {
        $this->install(\Sargilla\FlatLab\Facades\FlatLab::languages());
    }

    /**
     * Publish FlatLab package config.
     */
    private function publishConfig()
    {
        $this->install(\Sargilla\FlatLab\Facades\FlatLab::config());
    }

    /**
     * Install FlatLab views.
     */
    private function publishViews()
    {
        $this->install(\Sargilla\FlatLab\Facades\FlatLab::views());
    }

    /**
     * Install gravatar config file.
     */
    private function publishGravatar()
    {
       $this->install(\Sargilla\FlatLab\Facades\FlatLab::gravatar());
    }

    /**
     * Process options before running command.
     */
    private function processOptions()
    {
        $this->force = $this->option('force');
    }

}
