Skip to content

Commit e815743

Browse files
committed
feat(ext-terminal): add ShellSuggestContext class and documentation #1235
1 parent ed892d9 commit e815743

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

docs/customize/prompt-override.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ For example, create a file named `prompts/genius/sql/sql-gen-clarify.vm`, will o
4040
│ └── sql-gen-design.vm
4141
└── sre
4242
└── generate-dockerfile.vm
43-
```
43+
```

docs/features/shell-suggest.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: default
3+
title: Shell Suggest
4+
parent: Basic Features
5+
nav_order: 12
6+
permalink: /features/refactoring
7+
---
8+
9+
## Default context
10+
11+
```kotlin
12+
data class ShellSuggestContext(
13+
val question: String,
14+
val shellPath: String,
15+
val cwd: String,
16+
// today's date like 20240322
17+
val date: String = SimpleDateFormat("yyyyMMdd").format(Date()),
18+
// operating system name
19+
val os: String = System.getProperty("os.name")
20+
)
21+
```
22+

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/ShellCommandSuggestAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class ShellCommandSuggestAction : AnAction() {
5959
val options = TerminalProjectOptionsProvider.getInstance(project)
6060

6161
templateRender.context = ShellSuggestContext(
62-
data, options.shellPath, options.startingDirectory
62+
data, options.shellPath,
63+
options.startingDirectory
6364
?: project.guessProjectDir()?.path ?: System.getProperty("user.home")
6465
)
6566
val promptText = templateRender.renderTemplate(template)
@@ -159,4 +160,3 @@ class ShellCommandSuggestAction : AnAction() {
159160
}
160161
}
161162

162-
data class ShellSuggestContext(val question: String, val shellPath: String, val cwd: String)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cc.unitmesh.terminal
2+
3+
import java.text.SimpleDateFormat
4+
import java.util.*
5+
6+
data class ShellSuggestContext(
7+
val question: String,
8+
val shellPath: String,
9+
val cwd: String,
10+
// today's date like 20240322
11+
val date: String = SimpleDateFormat("yyyyMMdd").format(Date()),
12+
// operating system name
13+
val os: String = System.getProperty("os.name")
14+
)

0 commit comments

Comments
 (0)