mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
feat(cli): auto-submit prompt when using --prompt flag (#4510)
This commit is contained in:
parent
2d63c22d1a
commit
ed33d82535
2 changed files with 6 additions and 1 deletions
|
|
@ -44,6 +44,7 @@ export type PromptRef = {
|
|||
reset(): void
|
||||
blur(): void
|
||||
focus(): void
|
||||
submit(): void
|
||||
}
|
||||
|
||||
const PLACEHOLDERS = ["Fix a TODO in the codebase", "What is the tech stack of this project?", "Fix broken tests"]
|
||||
|
|
@ -447,11 +448,14 @@ export function Prompt(props: PromptProps) {
|
|||
})
|
||||
setStore("extmarkToPartIndex", new Map())
|
||||
},
|
||||
submit() {
|
||||
submit()
|
||||
},
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
if (props.disabled) return
|
||||
if (autocomplete.visible) return
|
||||
if (autocomplete?.visible) return
|
||||
if (!store.prompt.input) return
|
||||
const trimmed = store.prompt.input.trim()
|
||||
if (trimmed === "exit" || trimmed === "quit" || trimmed === ":q") {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ export function Home() {
|
|||
} else if (args.prompt) {
|
||||
prompt.set({ input: args.prompt, parts: [] })
|
||||
once = true
|
||||
prompt.submit()
|
||||
}
|
||||
})
|
||||
const directory = useDirectory()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue