Skip to content

Commit 8c8c557

Browse files
committedDec 20, 2023
custom gf-cli
1 parent 29e6920 commit 8c8c557

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed
 

‎src/main/kotlin/com/github/oldmegit/goframehelper/gf/Gf.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ object Gf {
1111
val goModMark = "github.com/gogf/gf/v2"
1212
val icon = IconLoader.getIcon("/icons/gf16.svg", Gf::class.java)
1313

14-
val gfGenCtrl = "gf gen ctrl"
15-
val gfGenService = "gf gen service"
16-
1714
val openApiTagGMeta = mapOf(
1815
"path" to "",
1916
"tags" to "",
@@ -70,4 +67,16 @@ object Gf {
7067
val settings = AppSettingsState.getInstance(project)
7168
return settings.gfEnableLogicWatch
7269
}
70+
71+
// get gf gen ctrl command
72+
fun gfGenCtrl(project: Project) : String {
73+
val settings = AppSettingsState.getInstance(project)
74+
return settings.gfCustomGfCli + " gen ctrl"
75+
}
76+
77+
// get gf gen ctrl command
78+
fun gfGenService(project: Project) : String {
79+
val settings = AppSettingsState.getInstance(project)
80+
return settings.gfCustomGfCli + " gen service"
81+
}
7382
}

‎src/main/kotlin/com/github/oldmegit/goframehelper/listener/Listener.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class Listener(private val project: Project): BulkFileListener {
3131
val runtime = Runtime.getRuntime()
3232
try {
3333
if (Gf.isApiFile(project, file) && Gf.enableApiWatch(project)) {
34-
runtime.exec(Gf.gfGenCtrl, null, File(project.basePath.toString()))
34+
runtime.exec(Gf.gfGenCtrl(project), null, File(project.basePath.toString()))
3535
} else if (Gf.isLogicFile(project, file) && Gf.enableLogicWatch(project)) {
36-
runtime.exec(Gf.gfGenService, null, File(project.basePath.toString()))
36+
runtime.exec(Gf.gfGenService(project), null, File(project.basePath.toString()))
3737
}
3838
} catch (_: Exception) {
3939
val message = Bundle.getMessage("gfExecErrNotify")

‎src/main/kotlin/com/github/oldmegit/goframehelper/ui/AppSettingsComponent.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ class AppSettingsComponent {
1111
val panel: JPanel
1212
private val apiDir = JBTextField()
1313
private val logicDir = JBTextField()
14+
private val customGfCli = JBTextField()
1415
private val enableApiWatch = JBCheckBox(Bundle.getMessage("setting.api.watch"))
1516
private val enableLogicWatch = JBCheckBox(Bundle.getMessage("setting.service.watch"))
1617

1718
init {
1819
panel = FormBuilder.createFormBuilder()
1920
.addLabeledComponent(JBLabel(Bundle.getMessage("setting.api.src")), apiDir, 1, false)
2021
.addLabeledComponent(JBLabel(Bundle.getMessage("setting.logic.src")), logicDir, 1, false)
22+
.addLabeledComponent(JBLabel(Bundle.getMessage("setting.custom.gfCli")), customGfCli, 1, false)
2123
.addComponent(enableApiWatch)
2224
.addComponent(enableLogicWatch)
2325
.addComponentFillVertically(JPanel(), 0)
@@ -27,13 +29,19 @@ class AppSettingsComponent {
2729
var gfApiDir: String?
2830
get() = apiDir.getText()
2931
set(newText) {
30-
apiDir.setText(newText)
32+
apiDir.text = newText
3133
}
3234

3335
var gfLogicDir: String?
3436
get() = logicDir.getText()
3537
set(newText) {
36-
logicDir.setText(newText)
38+
logicDir.text = newText
39+
}
40+
41+
var gfCustomGfCli: String?
42+
get() = customGfCli.getText()
43+
set(newText) {
44+
customGfCli.text = newText
3745
}
3846

3947
var gfEnableApiWatch: Boolean?

‎src/main/kotlin/com/github/oldmegit/goframehelper/ui/AppSettingsConfigurable.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class AppSettingsConfigurable(private val project: Project) : Configurable {
2525
val settings = AppSettingsState.getInstance(project)
2626
var modified = appSettingsComponent!!.gfApiDir != settings.gfApiDir
2727
modified = modified or (appSettingsComponent!!.gfLogicDir != settings.gfLogicDir)
28+
modified = modified or (appSettingsComponent!!.gfCustomGfCli != settings.gfCustomGfCli)
2829
modified = modified or (appSettingsComponent!!.gfEnableApiWatch != settings.gfEnableApiWatch)
2930
modified = modified or (appSettingsComponent!!.gfEnableLogicWatch != settings.gfEnableLogicWatch)
3031
return modified
@@ -34,6 +35,7 @@ class AppSettingsConfigurable(private val project: Project) : Configurable {
3435
val settings = AppSettingsState.getInstance(project)
3536
settings.gfApiDir = appSettingsComponent!!.gfApiDir!!
3637
settings.gfLogicDir = appSettingsComponent!!.gfLogicDir!!
38+
settings.gfCustomGfCli = appSettingsComponent!!.gfCustomGfCli!!
3739
settings.gfEnableApiWatch = appSettingsComponent!!.gfEnableApiWatch!!
3840
settings.gfEnableLogicWatch = appSettingsComponent!!.gfEnableLogicWatch!!
3941
}
@@ -42,6 +44,7 @@ class AppSettingsConfigurable(private val project: Project) : Configurable {
4244
val settings = AppSettingsState.getInstance(project)
4345
appSettingsComponent!!.gfApiDir = settings.gfApiDir
4446
appSettingsComponent!!.gfLogicDir = settings.gfLogicDir
47+
appSettingsComponent!!.gfCustomGfCli = settings.gfCustomGfCli
4548
appSettingsComponent!!.gfEnableApiWatch = settings.gfEnableApiWatch
4649
appSettingsComponent!!.gfEnableLogicWatch = settings.gfEnableLogicWatch
4750
}

‎src/main/kotlin/com/github/oldmegit/goframehelper/ui/AppSettingsState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
1515
internal class AppSettingsState : PersistentStateComponent<AppSettingsState> {
1616
var gfApiDir = "api"
1717
var gfLogicDir = "internal/logic"
18+
var gfCustomGfCli = "gf"
1819
var gfEnableApiWatch = true
1920
var gfEnableLogicWatch = true
2021

‎src/main/resources/message/GoFrameHelperBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ init=Init GoFrame Helper
44
# setting window
55
setting.api.src=Api src folder:
66
setting.logic.src=Logic src folder:
7+
setting.custom.gfCli=custom gf-cli:
78
setting.api.watch=Enable Api watch, it will auto exec `gf gen ctrl`
89
setting.service.watch=Enable Service watch, it will auto exec `gf gen service`
910

‎src/main/resources/message/GoFrameHelperBundle_zh.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ init=\u521d\u59cb\u5316 GoFrame Helper
44
# setting window
55
setting.api.src=Api \u76ee\u5f55:
66
setting.logic.src=Logic \u76ee\u5f55:
7+
setting.custom.gfCli=\u81ea\u5b9a\u4e49 gf-cli
78
setting.api.watch=\u542f\u7528 Api watch, \u5b83\u4f1a\u81ea\u52a8\u6267\u884c `gf gen ctrl`
89
setting.service.watch=\u542f\u7528 Service watch, \u5b83\u4f1a\u81ea\u52a8\u6267\u884c `gf gen service`
910

0 commit comments

Comments
 (0)