Skip to content

Commit b929f0f

Browse files
committed
Fix config command
1 parent c536583 commit b929f0f

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

common/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,20 @@ object ConfigCommand : LambdaCommand {
2727
builder.buildFuture()
2828
}
2929

30-
optional(string("config name")) { configName ->
31-
suggests { _, builder ->
32-
Configuration.configurations.map {
33-
it.configName
34-
}.forEach {
35-
builder.suggest(it)
36-
}
37-
builder.buildFuture()
30+
executeWithResult {
31+
val action = action().value()
32+
if (action !in actions) {
33+
return@executeWithResult failure("Invalid action $action. Did you mean ${actions.joinToString()}?")
3834
}
3935

40-
executeWithResult {
41-
val action = action().value()
42-
if (action !in actions) {
43-
return@executeWithResult failure("Invalid action $action. Did you mean ${actions.joinToString()}?")
44-
}
45-
46-
if (configName == null) {
47-
Configuration.configurations.forEach {
48-
when (action) {
49-
"save" -> it.trySave()
50-
else -> it.tryLoad()
51-
}
52-
}
53-
} else {
54-
val specificConfig = configName().value()
55-
56-
Configuration.configurations.find {
57-
it.configName == specificConfig
58-
}?.let {
59-
when (action) {
60-
"save" -> it.trySave()
61-
else -> it.tryLoad()
62-
}
63-
} ?: return@executeWithResult failure("No configuration found with name $specificConfig")
36+
Configuration.configurations.forEach {
37+
when (action) {
38+
"save" -> it.trySave()
39+
else -> it.tryLoad()
6440
}
65-
66-
success()
6741
}
42+
43+
success()
6844
}
6945
}
7046
}

0 commit comments

Comments
 (0)