3
3
4
4
namespace Swoft \Devtool \Command ;
5
5
6
- use Leuffen \TextTemplate \TemplateParsingException ;
7
- use ReflectionException ;
8
6
use Swoft \Bean \Annotation \Mapping \Inject ;
9
- use Swoft \Bean \Exception \ContainerException ;
10
7
use Swoft \Console \Annotation \Mapping \Command ;
11
8
use Swoft \Console \Annotation \Mapping \CommandArgument ;
12
9
use Swoft \Console \Annotation \Mapping \CommandMapping ;
13
10
use Swoft \Console \Annotation \Mapping \CommandOption ;
14
- use Swoft \Db \Exception \DbException ;
15
11
use Swoft \Db \Pool ;
16
12
use Swoft \Devtool \Model \Logic \EntityLogic ;
13
+ use Throwable ;
17
14
use function input ;
18
15
19
16
/**
@@ -41,16 +38,12 @@ class EntityCommand
41
38
* @CommandOption(name="table", desc="database table names", type="string")
42
39
* @CommandOption(name="pool", desc="database db pool default is 'db.pool'", type="string")
43
40
* @CommandOption(name="path", desc="generate entity file path", type="string", default="@app/Model/Entity")
44
- * @CommandOption(name="y", desc="generating entity file is confirm ", type="string")
41
+ * @CommandOption(name="y", desc="do you need confirmation? ", type="string")
45
42
* @CommandOption(name="field_prefix", desc="database field prefix ,alias is 'fp'", type="string")
46
- * @CommandOption(name="table_prefix", desc="like match database table prefix , alias is 'tp'", type="string")
47
- * @CommandOption(name="exclude", desc="expect generate database table entity , alias is 'exc'", type="string")
43
+ * @CommandOption(name="table_prefix", desc="like match database table prefix, alias is 'tp'", type="string")
44
+ * @CommandOption(name="exclude", desc="expect generate database table entity, alias is 'exc'", type="string")
48
45
* @CommandOption(name="td", desc="generate entity template path",type="string", default="@devtool/devtool/resource/template")
49
46
*
50
- * @throws TemplateParsingException
51
- * @throws ReflectionException
52
- * @throws ContainerException
53
- * @throws DbException
54
47
*/
55
48
public function create (): void
56
49
{
@@ -63,15 +56,19 @@ public function create(): void
63
56
$ exclude = input ()->getOpt ('exc ' , input ()->getOpt ('exclude ' ));
64
57
$ tplDir = input ()->getOpt ('td ' , '@devtool/devtool/resource/template ' );
65
58
66
- $ this ->logic ->create ([
67
- (string )$ table ,
68
- (string )$ tablePrefix ,
69
- (string )$ fieldPrefix ,
70
- (string )$ exclude ,
71
- (string )$ pool ,
72
- (string )$ path ,
73
- (bool )$ isConfirm ,
74
- (string )$ tplDir
75
- ]);
59
+ try {
60
+ $ this ->logic ->create ([
61
+ (string )$ table ,
62
+ (string )$ tablePrefix ,
63
+ (string )$ fieldPrefix ,
64
+ (string )$ exclude ,
65
+ (string )$ pool ,
66
+ (string )$ path ,
67
+ (bool )$ isConfirm ,
68
+ (string )$ tplDir
69
+ ]);
70
+ } catch (Throwable $ exception ) {
71
+ output ()->colored ($ exception ->getMessage (), 'error ' );
72
+ }
76
73
}
77
74
}
0 commit comments