Skip to content

Commit

Permalink
* 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecc-business-account committed Jun 27, 2022
1 parent 8c57e0c commit ff92180
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 59 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,8 @@ In a nutshell:
>
> Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix)
* 3.3 2022-06-27
* [CLI] updated CLI to 1.0
* 3.2 2022-06-27
* [CLI] updated CLI to 0.14
* 3.1.6 2022-06-24
Expand Down
19 changes: 10 additions & 9 deletions examples/clitest/testdb2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
"password": "abc.123",
"database": "testdb2",
"classdirectory": "testdb2",
"classpostfix": "Repo",
"classnamespace": "eftec\\examples\\clitest\\testdb2",
"namespace": null,
"savegen": "yes",
"tables": null,
"tablescolumns": "",
"tablescolumns": null,
"tablecommand": "",
"convertionselected": null,
"convertionnewvalue": null,
"newclassname": null,
"newclassname": "Product",
"overridegenerate": null,
"tablexclass": {
"cities": "CityRepo",
"categories": "CategoryRepo",
"customers": "CustomerRepo",
"customerxcategories": "CustomerXCategoryRepo",
"invoicedetails": "InvoicedetailRepo",
"invoices": "InvoiceRepo",
"products": "ProductRepo"
"cities": "City",
"categories": "Category",
"customers": "Customer",
"customerxcategories": "CustomerXCategory",
"invoicedetails": "InvoiceDetail",
"invoices": "Invoice",
"products": "Product"
},
"conversion": {
"bigint": null,
Expand Down
12 changes: 6 additions & 6 deletions lib/PdoOne.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php /** @noinspection PhpRedundantVariableDocTypeInspection */
<?php /** @noinspection PhpUnused */
/** @noinspection PhpRedundantVariableDocTypeInspection */
/** @noinspection SqlDialectInspection */
/** @noinspection SqlNoDataSourceInspection */
/** @noinspection PhpConditionAlreadyCheckedInspection */
Expand All @@ -25,11 +26,11 @@
* @package eftec
* @author Jorge Castro Castillo
* @copyright (c) Jorge Castro C. Dual Licence: MIT and Commercial License https://github.com/EFTEC/PdoOne
* @version 3.2
* @version 3.3
*/
class PdoOne
{
public const VERSION = '3.2';
public const VERSION = '3.3';
/** @var int We need this value because null and false could be a valid value. */
public const NULL = PHP_INT_MAX;
/** @var string Prefix of the tables */
Expand Down Expand Up @@ -126,9 +127,8 @@ class PdoOne
*/
public $customError = true;
/** @var string[] PHP classes excluded by the custom error log */
//todo: quitar comentarios
public $traceBlackList = []; //['PdoOne.php', 'PdoOneQuery.php', 'PdoOne_Mysql.php', 'PdoOne.Sqlsrv.php', 'PdoOne.Oci.php'
//, 'PdoOneTestMockup.php', '_BasePdoOneRepo.php'];
public $traceBlackList = ['PdoOne.php', 'PdoOneQuery.php', 'PdoOne_Mysql.php', 'PdoOne.Sqlsrv.php', 'PdoOne.Oci.php'
, 'PdoOneTestMockup.php', '_BasePdoOneRepo.php'];
/** @var PDO */
public $conn1;
/** @var bool True if the transaction is open */
Expand Down
79 changes: 35 additions & 44 deletions lib/PdoOneCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
* @package eftec
* @author Jorge Castro Castillo
* @copyright (c) Jorge Castro C. Dual Licence: MIT and Commercial License https://github.com/EFTEC/PdoOne
* @version 0.14
* @version 1.0
*/
class PdoOneCli
{
public const VERSION = '0.14';
public const VERSION = '1.0';
//</editor-fold>
/**
* @var array
Expand Down Expand Up @@ -262,6 +262,13 @@ public function cliEngine(): void
'Select the relative directory where the repository classes will be created',
['Example: repo'])
->setInput()->add();
$this->cli->createParam('classpostfix')
->setDefault('Repo')
->setCurrentAsDefault()
->setDescription('',
'Select the postfix of the class',
['Example: Repo'])
->setInput()->add();
$this->cli->createParam('classnamespace')
->setCurrentAsDefault()
->setDescription('',
Expand Down Expand Up @@ -354,7 +361,7 @@ public function cliEngine(): void
} else {
$this->cli->showCheck('OK', 'green', "Configuration PdoOneCli open $loadconfig->value");
$this->cli->setArrayParam($data
, [], ['databasetype', 'server', 'user', 'password', 'database', 'classdirectory', 'classnamespace']);
, [], ['databasetype', 'server', 'user', 'password', 'database', 'classdirectory', 'classpostfix', 'classnamespace']);
$this->tablexclass = $data['tablexclass'] ?? [];
$this->columnsTable = $data['columnsTable'] ?? [];
$this->columnsAlias = $data['columnsAlias'] ?? [];
Expand Down Expand Up @@ -443,18 +450,11 @@ public function cliEngine(): void
case '':
if (!$interactive) {
$this->cli->showParamSyntax2('Commands:', ['first'], [], null, null, 25);
$arr=$this->getArrayParameters();
$arr[]='overridegenerate';
$this->cli->showParamSyntax2('Flags common:',
['flag', 'longflag'],
['classdirectory',
'classnamespace',
'tables',
'tablescolumns',
'tablecommand',
'convertionselected',
'convertionnewvalue',
'newclassname',
'overridegenerate'
]
$arr
, null, 'common', 25);
}
return;
Expand All @@ -480,20 +480,20 @@ protected function showLogo(): void
");
}

/**
* List of the parameters to store, read and display in the help.
* @return string[]
*/
protected function getArrayParameters():array {
return ['classdirectory', 'classpostfix', 'classnamespace', 'tables', 'tablescolumns', 'tablecommand', 'convertionselected', 'convertionnewvalue', 'newclassname',];
}

protected function showHelpDefinition(): void
{
$this->cli->showParamSyntax2('Commands:', ['first'], [], null, null, 25);
$this->cli->showParamSyntax2('Flags for definition:',
['flag', 'longflag'],
['classdirectory',
'classnamespace',
'tables',
'tablescolumns',
'tablecommand',
'convertionselected',
'convertionnewvalue',
'newclassname',
]
$this->getArrayParameters()
, null, 'export', 25);
}

Expand All @@ -502,15 +502,7 @@ protected function showHelpGenerate(): void
$this->cli->showParamSyntax2('Commands:', ['first'], [], null, null, 25);
$this->cli->showParamSyntax2('Flags for generate:',
['flag', 'longflag'],
['classdirectory',
'classnamespace',
'tables',
'tablescolumns',
'tablecommand',
'convertionselected',
'convertionnewvalue',
'newclassname',
]
$this->getArrayParameters()
, null, 'generate', 25);
}

Expand All @@ -519,15 +511,7 @@ protected function showHelpExport(): void
$this->cli->showParamSyntax2('Commands:', ['first'], [], null, null, 25);
$this->cli->showParamSyntax2('Flags for export:',
['flag', 'longflag'],
['classdirectory',
'classnamespace',
'tables',
'tablescolumns',
'tablecommand',
'convertionselected',
'convertionnewvalue',
'newclassname',
]
$this->getArrayParameters()
, null, 'export', 25);
}

Expand Down Expand Up @@ -832,6 +816,7 @@ protected function databaseFolder(): void
$this->cli->show('</yellow>');
// $this->cli->showCheck('WARNING', 'yellow', 'unable to create directory ' . $ex->getMessage());
}
$this->cli->evalParam('classpostfix', true);
// dummy.
while (true) {
$this->cli->showCheck('info', 'yellow', 'The target path is ' . getcwd() . '/' . $this->cli->getValue('classdirectory'));
Expand All @@ -850,6 +835,7 @@ protected function databaseFolder(): void
$ce = class_exists($nameclass, true);
if ($ce) {
$this->cli->showCheck('ok', 'green', 'Namespace tested correctly');
@unlink($filename);
break;
}
$this->cli->showCheck('warning', 'yellow', 'Unable test namespace');
Expand Down Expand Up @@ -1079,11 +1065,16 @@ protected function runCliGeneration(): void
case 'end':
case $this->cli->emptyValue:
case '':
case 'create':
case 'convert':
if ($this->cli->getValue('classdirectory') && $this->cli->getValue('classnamespace')) {
$this->cli->evalParam('overridegenerate', true);
$pdo->generateCodeClassConversions($this->conversion);
$pdo->generateAllClasses($this->tablexclass, ucfirst($this->cli->getValue('database')),
$tmpTableXClass = [];
foreach ($this->tablexclass as $k => $v) {
$tmpTableXClass[$k] = $v . $this->cli->getValue('classpostfix');
}
$pdo->generateAllClasses($tmpTableXClass, ucfirst($this->cli->getValue('database')),
$this->cli->getValue('classnamespace'),
$this->cli->getValue('classdirectory'),
$this->cli->getValue('overridegenerate') === 'yes',
Expand Down Expand Up @@ -1144,7 +1135,7 @@ protected function databaseScan($tablesmarked, $pdo): void
$this->cli->showWaitCursor();
foreach ($tablesmarked as $table) {
$this->cli->showWaitCursor(false);
$class = PdoOne::tableCase($table) . 'Repo';
$class = PdoOne::tableCase($table);
//$classes[] = $class;
$tablexclass[$table] = $class;
$extracolumn[$table] = [];
Expand Down Expand Up @@ -1181,7 +1172,7 @@ protected function databaseScan($tablesmarked, $pdo): void
foreach ($tablexclass as $table => $v) {
if (!isset($this->tablexclass[$table])) {
$this->cli->showCheck(' added ', 'green', "table <bold>$table</bold> added");
$class = PdoOne::tableCase($table) . 'Repo';
$class = PdoOne::tableCase($table);
$this->tablexclass[$table] = $class;
$this->extracolumn[$table] = [];
}
Expand Down Expand Up @@ -1276,7 +1267,7 @@ protected function runCliSaveConfig($interactive): void
$sg = $this->cli->createParam('yn', [], 'none')
->setDescription('', 'Do you want to save the configuration of the connection?')
->setInput(true, 'optionshort', ['yes', 'no'])
->setDefault('yes')
->setDefault('no')
->evalParam(true);
if ($sg->value === 'yes') {
$saveconfig = $this->cli->evalParam('saveconfig', true);
Expand Down

0 comments on commit ff92180

Please sign in to comment.