Commit 27a5e15e authored by 谢宇轩's avatar 谢宇轩

fix: 优化生成器的输入解析

parent 7ab50762
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
use Jiwei\EasyHttpSdk\Generation\SdkEndpointBuilder; include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . "/../vendor/autoload.php"; use Jiwei\EasyHttpSdk\Generation\SdkEndpointBuilder;
$params = getopt("d:e:p:h", [ $params = getopt("d:e:p:h", [
"dist:", "dist:",
...@@ -15,27 +15,33 @@ $params = getopt("d:e:p:h", [ ...@@ -15,27 +15,33 @@ $params = getopt("d:e:p:h", [
if (isset($params['h']) || isset($params['help'])) { if (isset($params['h']) || isset($params['help'])) {
echo "SDK生成工具🧸ver:0.1\n echo "SDK生成工具🧸ver:0.1\n
-d --dist -d --dist
输出SDK Endpoint 类的目录 默认为 src/Endpoint 输出SDK Endpoint 类的目录 默认为 ./src/Endpoint/
-e --endpoints -e --endpoints
获取endpoins toml 描述文件的目录 endpoints 获取endpoins toml 描述文件的目录 ./endpoints/
-p--package -p--package
SDK Endpoint 类所使用的命名空间名称 ".PHP_EOL; SDK Endpoint 类所使用的命名空间名称 " . PHP_EOL;
exit; exit;
} }
$packageName = $params['p'] ?? $params['package'] ?? ""; $packageName = $params['p'] ?? $params['package'] ?? "";
$distPath = $params['d'] ?? $params['dist'] ?? __DIR__ . "/../src/EndPoint/"; $distPath = $params['d'] ?? $params['dist'] ?? __DIR__ . "./src/Endpoint/";
$endpointPath = $params['e'] ?? $params['endpoints'] ?? __DIR__ . "/../endpoints/"; $endpointPath = $params['e'] ?? $params['endpoints'] ?? __DIR__ . "./endpoints/";
if ("" === $packageName) { if ("" === $packageName) {
echo "请输入的包名" . PHP_EOL; echo "请输入的包名" . PHP_EOL;
exit; exit;
} }
var_dump($params); if (substr($distPath, -1) != "/") {
$distPath .= "/";
}
if (substr($endpointPath, -1) != "/") {
$endpointPath .= "/";
}
echo "正在创建{$packageName}" . PHP_EOL; echo "正在创建Jiwei\\{$packageName}\\Endpoint\\" . PHP_EOL;
echo "目标目录{$distPath}" . PHP_EOL; echo "目标目录{$distPath}" . PHP_EOL;
echo "配置来源{$endpointPath}" . PHP_EOL; echo "配置来源{$endpointPath}" . PHP_EOL;
......
...@@ -6,6 +6,7 @@ declare(strict_types=1); ...@@ -6,6 +6,7 @@ declare(strict_types=1);
namespace Jiwei\{{ Package }}\Endpoint; namespace Jiwei\{{ Package }}\Endpoint;
use Closure; use Closure;
use GuzzleHttp\Exception\GuzzleException;
use Jiwei\EasyHttpSdk\Application; use Jiwei\EasyHttpSdk\Application;
use Jiwei\EasyHttpSdk\Exception\SdkException; use Jiwei\EasyHttpSdk\Exception\SdkException;
use Jiwei\EasyHttpSdk\Exception\ApplicationException; use Jiwei\EasyHttpSdk\Exception\ApplicationException;
...@@ -49,6 +50,7 @@ class {{ Endpoint }} ...@@ -49,6 +50,7 @@ class {{ Endpoint }}
* @throws ApplicationException * @throws ApplicationException
* @throws SdkException * @throws SdkException
* @throws TimeOutExcetpion * @throws TimeOutExcetpion
* @throws GuzzleException
*/ */
public function {{ item.Action }}({{ item.Args }}?Closure $catch = null, ?Closure $then = null): mixed public function {{ item.Action }}({{ item.Args }}?Closure $catch = null, ?Closure $then = null): mixed
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment