#! /usr/bin/php
<?php
namespace GimliDev;

if (php_sapi_name() !== 'cli') {
    exit;
}

require_once 'vendor/autoload.php';

use GimliDev\Actions\Create_Init_Action;
use Clyde\Application;
use Clyde\Args\Arg_Flag;
use Clyde\Args\Arg_Option;
use Clyde\Commands\Command;
use Clyde\Tools\Emoji;
use GimliDev\Actions\Create_Controller_Action;
use GimliDev\Actions\Create_Logic_Action;
use GimliDev\Actions\Create_Model_Action;

define('ROOT', getcwd());
define('APP_ROOT', __DIR__);

Application::create('gimli')
	->version(Emoji::GREEN_BOX_WITH_CHECKMARK . ' v0.1.0')
	->about('Devtools for GimliDuck Framework')
	->author(Emoji::ALIEN_MONSTER . ' dvnc0')
	->helpTemplate(APP_ROOT . '/App/templates/help.txt')

	// Create devtools config
	->command(
		Command::create('init')
		->about('Create a devtools configuration file')
		->action(Create_Init_Action::class)
		->arg(
			Arg_Flag::create('force')
				->shortName('f')
				->help('Force overwrite existing configuration file')
				->defaultValue(false)
				->setTo(true)
				->longName('force')
				->save()
		)
		->save()
	)
	
	// Create a new controller
	->command(
		Command::create('controller <controller_name>')
		->about('Create a new controller')
		->action(Create_Controller_Action::class)
		->arg(
			Arg_Flag::create('single_action')
				->shortName('s')
				->help('Create a controller with a single action')
				->defaultValue(false)
				->setTo(true)
				->longName('single_action')
				->save()
		)
		->arg(
			Arg_Flag::create('resource')
				->shortName('r')
				->help('Create a controller with resource actions')
				->defaultValue(false)
				->setTo(true)
				->longName('resource')
				->save()
		)
		->arg(
			Arg_Option::create('namespace')
				->help('Set the namespace for the controller, remember to double escape \\')
				->shortName('n')
				->longName('namespace')
				->save()
		)
		->arg(
			Arg_Option::create('save_path')
				->help('Set the save path for the controller')
				->shortName('p')
				->longName('save_path')
				->save()
		)
		->save()
	)

	// Create a new logic file

	->command(
		Command::create('logic <logic_name>')
		->about('Create a new logic file')
		->action(Create_Logic_Action::class)
		->arg(
			Arg_Option::create('namespace')
				->help('Set the namespace for the logic file, remember to double escape \\')
				->shortName('n')
				->longName('namespace')
				->save()
		)
		->arg(
			Arg_Option::create('save_path')
				->help('Set the save path for the logic file')
				->shortName('p')
				->longName('save_path')
				->save()
		)
		->save()
	
	)

	// Create a new model

	->command(
		Command::create('model <model_name>')
		->about('Create a new model')
		->action(Create_Model_Action::class)
		->arg(
			Arg_Option::create('namespace')
				->help('Set the namespace for the model, remember to double escape \\')
				->shortName('n')
				->longName('namespace')
				->save()
		)
		->arg(
			Arg_Option::create('save_path')
				->help('Set the save path for the model')
				->shortName('p')
				->longName('save_path')
				->save()
		)
		->arg(
			Arg_Option::create('table')
				->help('Set the table name for the model')
				->shortName('t')
				->longName('table')
				->defaultValue('')
				->save()
		)
		->arg(
			Arg_Option::create('primary_key')
				->help('Set the primary key for the model')
				->shortName('k')
				->longName('primary_key')
				->defaultValue('id')
				->save()
		)
		->save()
	)

	// TODO:

	// Create a new view

	// Create a new middleware

	// Create a migration

	// Create a route file

	// Add a route to a route file

	// Add a Vue file

	// Create a skeleton project

	// Run Vue build

	// Run TailwindCSS build

	// Run migrations

->run();
