Skip to content

Commit

Permalink
File Location Displayed when displying file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Nov 25, 2020
1 parent 1e79018 commit c6b4b07
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Commands/MakeConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MakeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/MakeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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'));
Expand Down Expand Up @@ -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'));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/Commands/MakeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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',
];

/**
Expand All @@ -52,8 +54,7 @@ class MakeModel extends BaseCommand
*/
protected $options = [
'-n' => 'Set model namespace',
'-t' => 'Set model Database table',

'-t' => 'Set Model Database table',
];

/**
Expand All @@ -63,30 +64,29 @@ 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)) {
CLI::error(lang('Recharge.badName'));
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)) {
Expand Down Expand Up @@ -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'));
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/Commands/MakeSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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',
];

/**
Expand All @@ -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');
Expand All @@ -76,10 +81,6 @@ public function run(array $params = [])
return;
}

helper(['inflector', 'filesystem']);

$file = new FileHandler();

//namespace locator
$nsinfo = $file->getNamespaceInfo($ns, 'App');

Expand Down Expand Up @@ -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'));
}
}
}
Expand Down

0 comments on commit c6b4b07

Please sign in to comment.