Skip to content

Commit 3fcc07a

Browse files
authored
Merge pull request #2 from wxiaoguang/migrate-to-urfave-v3
Don't call newAuthService in init stage
2 parents d4a27cb + 38933ea commit 3fcc07a

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

cmd/admin_auth_oauth.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,22 @@ func oauthCLIFlags() []cli.Flag {
126126

127127
func microcmdAuthAddOauth() *cli.Command {
128128
return &cli.Command{
129-
Name: "add-oauth",
130-
Usage: "Add new Oauth authentication source",
131-
Action: newAuthService().runAddOauth,
132-
Flags: oauthCLIFlags(),
129+
Name: "add-oauth",
130+
Usage: "Add new Oauth authentication source",
131+
Action: func(ctx context.Context, cmd *cli.Command) error {
132+
return newAuthService().runAddOauth(ctx, cmd)
133+
},
134+
Flags: oauthCLIFlags(),
133135
}
134136
}
135137

136138
func microcmdAuthUpdateOauth() *cli.Command {
137139
return &cli.Command{
138-
Name: "update-oauth",
139-
Usage: "Update existing Oauth authentication source",
140-
Action: newAuthService().runUpdateOauth,
140+
Name: "update-oauth",
141+
Usage: "Update existing Oauth authentication source",
142+
Action: func(ctx context.Context, cmd *cli.Command) error {
143+
return newAuthService().runUpdateOauth(ctx, cmd)
144+
},
141145
Flags: append(oauthCLIFlags()[:1], append([]cli.Flag{&cli.Int64Flag{
142146
Name: "id",
143147
Usage: "ID of authentication source",

cmd/admin_auth_smtp.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ func smtpCLIFlags() []cli.Flag {
7676

7777
func microcmdAuthUpdateSMTP() *cli.Command {
7878
return &cli.Command{
79-
Name: "update-smtp",
80-
Usage: "Update existing SMTP authentication source",
81-
Action: newAuthService().runUpdateSMTP,
79+
Name: "update-smtp",
80+
Usage: "Update existing SMTP authentication source",
81+
Action: func(ctx context.Context, cmd *cli.Command) error {
82+
return newAuthService().runUpdateSMTP(ctx, cmd)
83+
},
8284
Flags: append(smtpCLIFlags()[:1], append([]cli.Flag{&cli.Int64Flag{
8385
Name: "id",
8486
Usage: "ID of authentication source",
@@ -88,10 +90,12 @@ func microcmdAuthUpdateSMTP() *cli.Command {
8890

8991
func microcmdAuthAddSMTP() *cli.Command {
9092
return &cli.Command{
91-
Name: "add-smtp",
92-
Usage: "Add new SMTP authentication source",
93-
Action: newAuthService().runAddSMTP,
94-
Flags: smtpCLIFlags(),
93+
Name: "add-smtp",
94+
Usage: "Add new SMTP authentication source",
95+
Action: func(ctx context.Context, cmd *cli.Command) error {
96+
return newAuthService().runAddSMTP(ctx, cmd)
97+
},
98+
Flags: smtpCLIFlags(),
9599
}
96100
}
97101

0 commit comments

Comments
 (0)