This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af6abe6
commit f65dd8e
Showing
6 changed files
with
125 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2020-12-26 23:23:54 | ||
* @modify date 2020-12-27 00:20:24 | ||
* @desc [description] | ||
*/ | ||
|
||
namespace SLiMSTarsius; | ||
|
||
class Docgenerator | ||
{ | ||
public static function banner() | ||
{ | ||
echo " _____ _ | ||
|_ _|_ _ _ __ ___(_)_ _ ___ | ||
| |/ _` | '__/ __| | | | / __| | ||
| | (_| | | \__ \ | |_| \__ \ | ||
|_|\__,_|_| |___/_|\__,_|___/ | ||
"; | ||
echo "\t\t\t v1.1.0 \n"; | ||
} | ||
public static function firstMeet() | ||
{ | ||
// Greeting | ||
self::banner(); | ||
echo "\n Hai, ini tarsius perkakas pengembangan untuk \e[36mSLiMS \033[0m:D\n"; | ||
// usage documentation | ||
self::usage(); | ||
} | ||
|
||
public static function usage() | ||
{ | ||
// Start doc | ||
echo "\n\e[33m Penggunaan \033[0m\n"; | ||
echo "\n"; | ||
echo " php tarsius [perintah] [parameter]"; | ||
echo "\n"; | ||
echo "\n\e[33m Perintah Tersedia \033[0m\n"; | ||
/* Plugin */ | ||
echo "\n\e[36m --plugin \033[0m"; | ||
echo "\n\e[32m --plugin:create \033[0m\tMembuat kerangka dasar plugin (mode non-hook)"; | ||
echo "\n\e[32m --plugin:enable \033[0m\tMengaktifkan plugin (fitur mendatang)"; | ||
echo "\n\e[32m --plugin:disable \033[0m\tMeng-non-aktifkan plugin (fitur mendatang)"; | ||
echo "\n\e[32m --plugin:delete \033[0m\tMenghapus plugin (fitur mendatang)"; | ||
echo "\n\e[32m --plugin:list \033[0m\tMenampilkan plugin tersedia (fitur mendatang)"; | ||
echo "\n\e[32m --plugin:info \033[0m\tMenampilkan informasi plugin (fitur mendatang)\n"; | ||
/* Module */ | ||
echo "\n\e[36m --module \033[0m"; | ||
echo "\n\e[32m --module:create \033[0m\tMembuat kerangka dasar module (fitur mendatang)"; | ||
echo "\n\e[32m --module:list \033[0m\tMenampilkan module tersedia (fitur mendatang)"; | ||
echo "\n\e[32m --module:info \033[0m\tMenampilkan informasi module (fitur mendatang)\n"; | ||
/* Template */ | ||
echo "\n\e[36m --template \033[0m\t(fitur mendatang)\n"; | ||
/* Library */ | ||
echo "\n\e[36m --library \033[0m\t(fitur mendatang)\n"; | ||
/* REST APi */ | ||
echo "\n\e[36m --rest-api \033[0m\t(fitur mendatang)\n"; | ||
echo "\n\e[33m Contoh Penggunaan \033[0m\n"; | ||
echo "\n"; | ||
|
||
echo " php tarsius --plugin:create buku_induk\n"; | ||
echo "\n"; | ||
} | ||
|
||
public static function failedMsg($message, $pointMessage) | ||
{ | ||
die(str_replace("{pointMsg}", "\e[1m\e[31m$pointMessage\033[0m", "\n\e[1mError\033[0m:\n\n$message")."\n\n"); | ||
} | ||
|
||
public static function successMsg($message, $pointMessage) | ||
{ | ||
die(str_replace("{pointMsg}", "\e[1m\e[92m$pointMessage\033[0m", $message)."\n\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,13 @@ | |
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2020-12-26 17:02:45 | ||
* @modify date 2020-12-26 17:03:16 | ||
* @modify date 2020-12-27 00:20:27 | ||
*/ | ||
|
||
namespace SLiMSTarsius; | ||
|
||
use \SLiMSTarsius\Docgenerator as dg; | ||
|
||
class Plugin | ||
{ | ||
public $env; | ||
|
@@ -26,7 +28,7 @@ public function create($dest, $pluginName) | |
'version' => 'Version (Minimal gunakan semantic versioning)', | ||
'author' => 'Author (Pembuat)', | ||
'author_uri' => 'Author URI (Halaman profil pembuat)', | ||
'target_module' => 'Modul tujuan?', | ||
'target_module' => 'Modul tujuan', | ||
'label_menu' => 'Teks yang muncul di Menu?' | ||
]; | ||
|
||
|
@@ -35,13 +37,13 @@ public function create($dest, $pluginName) | |
|
||
if (count($pluginName) > 1) | ||
{ | ||
die("Hanya bisa membuat 1 plugin dalam 1 perintah!\n"); | ||
dg::failedMsg("{pointMsg}", 'Hanya bisa membuat 1 plugin dalam 1 perintah!'); | ||
} | ||
|
||
$pluginName = $pluginName[0]; | ||
|
||
// set message | ||
echo 'Membuat plugin '.$pluginName."\n"; | ||
echo "\nMembuat plugin \e[36m$pluginName\033[0m\n\n"; | ||
// get information and make plugin | ||
$this->makeInteractive($interactiveMap) | ||
->makePlugin($pluginName, $destinantion, $template); | ||
|
@@ -52,15 +54,15 @@ private function makeInteractive($label) | |
if (is_array($label)) | ||
{ | ||
foreach ($label as $key => $question) { | ||
echo $question.' plugin? [tuliskan] '; | ||
echo "\e[1m$question plugin?\033[0m [tuliskan] "; | ||
$this->interactiveResponse[$key] = trim(fgets(STDIN)); | ||
} | ||
|
||
return $this; | ||
} | ||
else | ||
{ | ||
die('Label harus Array!'); | ||
dg::failedMsg("{pointMsg} harus Array!", 'Label'); | ||
} | ||
} | ||
|
||
|
@@ -78,8 +80,18 @@ private function makePlugin($pluginName, $destDir, $template) | |
$this->interactiveResponse['date_created'] = date('Y-m-d H:i:s'); | ||
|
||
foreach ($this->interactiveResponse as $key => $value) { | ||
$dotPlugin = str_replace('{'.$key.'}', $value, $dotPlugin); | ||
$indexPlugin = str_replace('{'.$key.'}', $value, $indexPlugin); | ||
if (!empty(trim($this->interactiveResponse[$key]))) | ||
{ | ||
$dotPlugin = str_replace('{'.$key.'}', $value, $dotPlugin); | ||
$indexPlugin = str_replace('{'.$key.'}', $value, $indexPlugin); | ||
} | ||
else | ||
{ | ||
// remove directory | ||
rmdir($destDir.$pluginName); | ||
// set message | ||
dg::failedMsg("Parameter {pointMsg} tidak boleh kosong!", $key); | ||
} | ||
} | ||
|
||
try { | ||
|
@@ -89,20 +101,20 @@ private function makePlugin($pluginName, $destDir, $template) | |
|
||
if ($dotPlugin && $indexPlugin) | ||
{ | ||
echo "Berhasil membuat plugin $pluginName \n"; | ||
dg::successMsg("{pointMsg}", "\nBerhasil membuat plugin $pluginName"); | ||
} | ||
} catch (\ErrorException $e) { | ||
die("Gagal membuat plugin $pluginName : \n ".$e->getMessage()); | ||
dg::failedMsg("Gagal membuat plugin {pointMsg} : $e->getMessage()", $pluginName); | ||
} | ||
} | ||
else | ||
{ | ||
die('Gagal membuat direktori plugin!'); | ||
dg::failedMsg("{pointMsg}", "Gagal membuat direktori plugin"); | ||
} | ||
} | ||
else | ||
{ | ||
die('Plugin sudah ada. Ingin membuat plugin lagi? Hapus plugin yang sudah ada.'."\n"); | ||
dg::failedMsg("{pointMsg}", "Plugin sudah ada. Ingin membuat plugin lagi? Hapus plugin yang sudah ada."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2020-12-26 17:02:45 | ||
* @modify date 2020-12-26 17:03:16 | ||
* @modify date 2020-12-27 00:20:21 | ||
*/ | ||
|
||
namespace SLiMSTarsius; | ||
|
@@ -17,7 +17,21 @@ class Tarmagick | |
public static function plugin($action) | ||
{ | ||
self::getEnvironment(self::$dir); | ||
echo (new \SLiMSTarsius\Plugin(self::$environment))->$action(self::$dir, self::$parameter); | ||
|
||
try { | ||
$Plugin = new \SLiMSTarsius\Plugin(self::$environment); | ||
|
||
if (method_exists($Plugin, $action)) | ||
{ | ||
$Plugin->$action(self::$dir, self::$parameter); | ||
} | ||
else | ||
{ | ||
throw new \ErrorException($action); | ||
} | ||
} catch (\ErrorException $e) { | ||
\SLiMSTarsius\Docgenerator::failedMsg("Metode {pointMsg} tidak ada!", $e->getMessage()); | ||
} | ||
} | ||
|
||
public static function module($action) | ||
|
@@ -60,14 +74,10 @@ public static function startup($mainDirectory) | |
self::$parameter = $parser->arguments['parameter']; | ||
return self::$method($parser->arguments['method'][1]); | ||
} | ||
else | ||
{ | ||
echo "Metode tidak tersedia!"; | ||
} | ||
} | ||
else | ||
{ | ||
echo "Hai, ini tarsius perkakas pengemban untuk SLiMS :D \n"; | ||
\SLiMSTarsius\Docgenerator::firstMeet(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.