From c6b4b07e637121610833b7eb33196c571cdbc3fe Mon Sep 17 00:00:00 2001 From: Hafijul Islam Date: Wed, 25 Nov 2020 17:53:02 +0600 Subject: [PATCH] File Location Displayed when displying file creation --- src/Commands/MakeConfig.php | 2 +- src/Commands/MakeEntity.php | 2 +- src/Commands/MakeFilter.php | 2 +- src/Commands/MakeMigration.php | 6 +++--- src/Commands/MakeModel.php | 24 ++++++++++++------------ src/Commands/MakeSeeder.php | 17 +++++++++-------- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Commands/MakeConfig.php b/src/Commands/MakeConfig.php index e5273e9..b2e8ce9 100644 --- a/src/Commands/MakeConfig.php +++ b/src/Commands/MakeConfig.php @@ -111,7 +111,7 @@ public function run(array $params = []) return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } } diff --git a/src/Commands/MakeEntity.php b/src/Commands/MakeEntity.php index 2cbf571..ea46d17 100644 --- a/src/Commands/MakeEntity.php +++ b/src/Commands/MakeEntity.php @@ -117,7 +117,7 @@ public function run(array $params = []) return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } } diff --git a/src/Commands/MakeFilter.php b/src/Commands/MakeFilter.php index 22974d7..ae2648e 100644 --- a/src/Commands/MakeFilter.php +++ b/src/Commands/MakeFilter.php @@ -105,7 +105,7 @@ public function run(array $params = []) return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } } diff --git a/src/Commands/MakeMigration.php b/src/Commands/MakeMigration.php index 9553326..08cfa96 100644 --- a/src/Commands/MakeMigration.php +++ b/src/Commands/MakeMigration.php @@ -64,7 +64,7 @@ class MakeMigration extends BaseCommand ]; /** - * Creates a new entity file with the current timestamp. + * Creates a new migration file with the current timestamp. * @param array $params * @return void */ @@ -80,7 +80,7 @@ public function run(array $params = []) $alltables = $params['-all'] ?? CLI::getOption('all'); if (empty($name) && is_null($alltables)) - $name = CLI::prompt(lang('Recharge.migrateName')); + $name = CLI::prompt(lang('Recharge.migrateName'), null, 'string'); if (empty($name) && is_null($alltables)) { CLI::error(lang('Recharge.badName')); @@ -150,7 +150,7 @@ public function generateMigration(string $timestamp, string $ns, string $targetD CLI::error(lang('Recharge.writeError', [$filepath])); return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } } diff --git a/src/Commands/MakeModel.php b/src/Commands/MakeModel.php index def1ff3..250b037 100644 --- a/src/Commands/MakeModel.php +++ b/src/Commands/MakeModel.php @@ -6,7 +6,9 @@ use Hafiz\Libraries\FileHandler; /** - * Creates a new Entity file. + * Make Command Class for a skeleton Model Class + * model Class that collect property from table + * * @package CodeIgniter\Commands * @extend BaseCommand */ @@ -30,7 +32,7 @@ class MakeModel extends BaseCommand * The Command's short description * @var string */ - protected $description = 'Creates a Model file [NB: FOLDER NAMED `Entities` IS NECESSARY].'; + protected $description = 'Creates a Model file.'; /** * The Command's usage @@ -43,7 +45,7 @@ class MakeModel extends BaseCommand * @var array */ protected $arguments = [ - 'model_name' => 'The database model file name', + 'model_name' => 'The Model file name', ]; /** @@ -52,8 +54,7 @@ class MakeModel extends BaseCommand */ protected $options = [ '-n' => 'Set model namespace', - '-t' => 'Set model Database table', - + '-t' => 'Set Model Database table', ]; /** @@ -63,12 +64,15 @@ class MakeModel extends BaseCommand */ public function run(array $params = []) { + helper(['inflector', 'filesystem']); + $file = new FileHandler(); + $name = array_shift($params); $ns = $params['-n'] ?? CLI::getOption('n'); $table = $params['-t'] ?? CLI::getOption('t'); if (empty($name)) { - $name = CLI::prompt(lang('Recharge.modelName')); + $name = CLI::prompt(lang('Recharge.modelName'), null, 'required|string'); } if (empty($name)) { @@ -76,17 +80,13 @@ public function run(array $params = []) return; } - helper(['inflector', 'filesystem']); - - $file = new FileHandler(); - //namespace locator $nsinfo = $file->getNamespaceInfo($ns, 'App'); //class & file name - $name = singular(pascalize($name)) . (stripos($name, 'Model') === FALSE ? 'Model' : ''); $ns = $nsinfo['ns']; $targetDir = $nsinfo['path'] . '/Models/'; + $name = singular(pascalize($name)) . (stripos($name, 'Model') === FALSE ? 'Model' : ''); $filepath = $targetDir . $name . '.php'; if ($file->verifyDirectory($filepath)) { @@ -136,7 +136,7 @@ public function run(array $params = []) return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } } diff --git a/src/Commands/MakeSeeder.php b/src/Commands/MakeSeeder.php index e660c5c..8fdae65 100644 --- a/src/Commands/MakeSeeder.php +++ b/src/Commands/MakeSeeder.php @@ -6,7 +6,9 @@ use Hafiz\Libraries\FileHandler; /** - * Creates a new Entity file. + * Make Commadn for Seeder File Generation Class + * Seeder can be skeleton aor loaded from a database table + * * @package CodeIgniter\Commands * @extend BaseCommand */ @@ -30,7 +32,7 @@ class MakeSeeder extends BaseCommand * The Command's short description * @var string */ - protected $description = 'Creates a seeder file [NB: FOLDER NAMED `Entities` IS NECESSARY].'; + protected $description = 'Creates a Seeder file.'; /** * The Command's usage @@ -43,7 +45,7 @@ class MakeSeeder extends BaseCommand * @var array */ protected $arguments = [ - 'seed_name' => 'The database entity file name', + 'seed_name' => 'The Seeder file name', ]; /** @@ -63,6 +65,9 @@ class MakeSeeder extends BaseCommand */ public function run(array $params = []) { + helper(['inflector', 'filesystem']); + $file = new FileHandler(); + $name = array_shift($params); $ns = $params['-n'] ?? CLI::getOption('n'); $table = $params['-t'] ?? CLI::getOption('t'); @@ -76,10 +81,6 @@ public function run(array $params = []) return; } - helper(['inflector', 'filesystem']); - - $file = new FileHandler(); - //namespace locator $nsinfo = $file->getNamespaceInfo($ns, 'App'); @@ -110,7 +111,7 @@ public function run(array $params = []) return; } - CLI::write('Created file: ' . CLI::color(basename($filepath), 'green')); + CLI::write('Created file: ' . CLI::color($filepath, 'green')); } } }