Skip to content

Commit 1ded5ea

Browse files
initial skeleton for db studio command
1 parent e2e3abc commit 1ded5ea

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

packages/cli/src/main/kotlin/elide/tool/cli/Elide.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import elide.runtime.gvm.internals.intrinsics.ElideIntrinsic
4343
import elide.tool.cli.cfg.ElideCLITool.ELIDE_TOOL_VERSION
4444
import elide.tool.cli.cmd.builder.ToolBuildCommand
4545
import elide.tool.cli.cmd.builder.ToolWhichCommand
46+
import elide.tool.cli.cmd.db.DbCommand
4647
import elide.tool.cli.cmd.deps.AddCommand
4748
import elide.tool.cli.cmd.deps.InstallCommand
4849
import elide.tool.cli.cmd.dev.DevCommand
@@ -132,6 +133,7 @@ internal const val ELIDE_HEADER = ("@|bold,fg(magenta)%n" +
132133
McpCommand::class,
133134
Elide.Completions::class,
134135
ToolSecretsCommand::class,
136+
DbCommand::class,
135137
],
136138
customSynopsis = [
137139
"",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package elide.tool.cli.cmd.db
2+
3+
import io.micronaut.core.annotation.Introspected
4+
import io.micronaut.core.annotation.ReflectiveAccess
5+
import picocli.CommandLine.Command
6+
import picocli.CommandLine.Option
7+
import elide.tool.cli.CommandContext
8+
import elide.tool.cli.CommandResult
9+
import elide.tool.cli.ProjectAwareSubcommand
10+
import elide.tool.cli.ToolState
11+
12+
@Command(
13+
name = "db",
14+
description = ["Database tools for Elide projects."],
15+
mixinStandardHelpOptions = true,
16+
subcommands = [DbStudioCommand::class],
17+
)
18+
@Introspected
19+
@ReflectiveAccess
20+
internal class DbCommand : ProjectAwareSubcommand<ToolState, CommandContext>() {
21+
override suspend fun CommandContext.invoke(state: ToolContext<ToolState>): CommandResult {
22+
return err("`elide db` requires a subcommand (try: studio)")
23+
}
24+
}
25+
26+
@Command(
27+
name = "studio",
28+
description = ["Launch database UI for SQLite databases"],
29+
mixinStandardHelpOptions = true,
30+
)
31+
@Introspected
32+
@ReflectiveAccess
33+
internal class DbStudioCommand : ProjectAwareSubcommand<ToolState, CommandContext>() {
34+
35+
@Option(
36+
names = ["--port", "-p"],
37+
description = ["Port to run the database UI on"],
38+
defaultValue = "4983",
39+
)
40+
internal var port: Int = 4983
41+
42+
@Option(
43+
names = ["--host"],
44+
description = ["Host to bind the database UI to"],
45+
defaultValue = "localhost",
46+
)
47+
internal var host: String = "localhost"
48+
49+
override suspend fun CommandContext.invoke(state: ToolContext<ToolState>): CommandResult {
50+
output {
51+
append("Starting database UI on http://$host:$port")
52+
}
53+
54+
// TODO
55+
56+
return success()
57+
}
58+
}

0 commit comments

Comments
 (0)