33
44namespace Swoft \Devtool \Command ;
55
6- use Leuffen \TextTemplate \TemplateParsingException ;
7- use ReflectionException ;
86use Swoft \Bean \Annotation \Mapping \Inject ;
9- use Swoft \Bean \Exception \ContainerException ;
107use Swoft \Console \Annotation \Mapping \Command ;
118use Swoft \Console \Annotation \Mapping \CommandArgument ;
129use Swoft \Console \Annotation \Mapping \CommandMapping ;
1310use Swoft \Console \Annotation \Mapping \CommandOption ;
14- use Swoft \Db \Exception \DbException ;
1511use Swoft \Db \Pool ;
1612use Swoft \Devtool \Model \Logic \EntityLogic ;
13+ use Throwable ;
1714use function input ;
1815
1916/**
@@ -41,16 +38,12 @@ class EntityCommand
4138 * @CommandOption(name="table", desc="database table names", type="string")
4239 * @CommandOption(name="pool", desc="database db pool default is 'db.pool'", type="string")
4340 * @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")
4542 * @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")
4845 * @CommandOption(name="td", desc="generate entity template path",type="string", default="@devtool/devtool/resource/template")
4946 *
50- * @throws TemplateParsingException
51- * @throws ReflectionException
52- * @throws ContainerException
53- * @throws DbException
5447 */
5548 public function create (): void
5649 {
@@ -63,15 +56,19 @@ public function create(): void
6356 $ exclude = input ()->getOpt ('exc ' , input ()->getOpt ('exclude ' ));
6457 $ tplDir = input ()->getOpt ('td ' , '@devtool/devtool/resource/template ' );
6558
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+ }
7673 }
7774}
0 commit comments