Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Easy Http SDK
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Back End
Easy Http SDK
Commits
27a5e15e
Commit
27a5e15e
authored
Feb 17, 2023
by
谢宇轩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 优化生成器的输入解析
parent
7ab50762
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
easysdk
bin/easysdk
+19
-13
Endpoint.temp
template/Endpoint.temp
+3
-1
No files found.
bin/easysdk
View file @
27a5e15e
#!/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:"
,
...
@@ -14,28 +14,34 @@ $params = getopt("d:e:p:h", [
...
@@ -14,28 +14,34 @@ $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/EndP
oint/"
;
$distPath
=
$params
[
'd'
]
??
$params
[
'dist'
]
??
__DIR__
.
"
./src/Endp
oint/"
;
$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
;
...
@@ -49,4 +55,4 @@ $builder = new SdkEndpointBuilder(
...
@@ -49,4 +55,4 @@ $builder = new SdkEndpointBuilder(
$count
=
$builder
->
build
();
$count
=
$builder
->
build
();
echo
"成功生成
{
$count
}
个 Endpoint Class"
.
PHP_EOL
;
echo
"成功生成
{
$count
}
个 Endpoint Class"
.
PHP_EOL
;
\ No newline at end of file
template/Endpoint.temp
View file @
27a5e15e
...
@@ -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
{
{
...
@@ -80,4 +82,4 @@ class {{ Endpoint }}
...
@@ -80,4 +82,4 @@ class {{ Endpoint }}
{
%
endfor
%
}
{
%
endfor
%
}
}
}
{
%
endautoescape
%
}
{
%
endautoescape
%
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment