Skip to content

Commit

Permalink
feat(ext-terminal): add ShellSuggestContext class and documentation #…
Browse files Browse the repository at this point in the history
…1235
  • Loading branch information
phodal committed Apr 4, 2024
1 parent ed892d9 commit e815743
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/customize/prompt-override.md
Expand Up @@ -40,4 +40,4 @@ For example, create a file named `prompts/genius/sql/sql-gen-clarify.vm`, will o
│ └── sql-gen-design.vm
└── sre
└── generate-dockerfile.vm
```
```
22 changes: 22 additions & 0 deletions docs/features/shell-suggest.md
@@ -0,0 +1,22 @@
---
layout: default
title: Shell Suggest
parent: Basic Features
nav_order: 12
permalink: /features/refactoring
---

## Default context

```kotlin
data class ShellSuggestContext(
val question: String,
val shellPath: String,
val cwd: String,
// today's date like 20240322
val date: String = SimpleDateFormat("yyyyMMdd").format(Date()),
// operating system name
val os: String = System.getProperty("os.name")
)
```

Expand Up @@ -59,7 +59,8 @@ class ShellCommandSuggestAction : AnAction() {
val options = TerminalProjectOptionsProvider.getInstance(project)

templateRender.context = ShellSuggestContext(
data, options.shellPath, options.startingDirectory
data, options.shellPath,
options.startingDirectory
?: project.guessProjectDir()?.path ?: System.getProperty("user.home")
)
val promptText = templateRender.renderTemplate(template)
Expand Down Expand Up @@ -159,4 +160,3 @@ class ShellCommandSuggestAction : AnAction() {
}
}

data class ShellSuggestContext(val question: String, val shellPath: String, val cwd: String)
@@ -0,0 +1,14 @@
package cc.unitmesh.terminal

import java.text.SimpleDateFormat
import java.util.*

data class ShellSuggestContext(
val question: String,
val shellPath: String,
val cwd: String,
// today's date like 20240322
val date: String = SimpleDateFormat("yyyyMMdd").format(Date()),
// operating system name
val os: String = System.getProperty("os.name")
)

0 comments on commit e815743

Please sign in to comment.