Closed lublak closed 8 months ago
@lublak It would have been better if you write an API proposal with new syntax.
If I understand it you want to save the text entered in promptStringRemember
in a file and return and remember the file path.
Possible syntax would be:
"inputs": [
{
"id": "promptText",
"type": "command",
"command": "extension.commandvariable.promptStringRemember",
"args": {
"key": "text",
"description": "Enter a text",
"saveFile": "${workspaceFolder}/.vscode/tmp-text.txt"
}
}
]
The user has to construct a file path to use.
When you use ${input:promptText}
you get a OS file system file path that contains the text in UTF-8 format.
It will also be implemented for pickStringRemember
@rioj7 sry.
Yes this would one solution. Another solution would be: This would also be usefull
"inputs": [
{
"id": "promptText",
"type": "command",
"command": "extension.commandvariable.promptStringRemember",
"args": {
"key": "text",
"description": "Enter a text",
}
},
{
"id": "textTmpFile",
"type": "command",
"command": "extension.commandvariable.file.save",
"args": {
"key": "text",
"file": "${workspaceFolder}/.vscode/tmp-text.txt"
}
}
]
This might also be useful if you need it outside of the prompt. That way it would be more modular.
@lublak Your textTmpFile
input would duplicate the promptStringRemember
behavior with the only difference that it saves to a file, why not add that feature to promptStringRemember
. And it is not clear what is the GUI used to get the content of the file. Just like key
is additional functionality of promptStringRemember
to put the result in a semi persistent storage.
And when I save the file path the way it is done in pickFile
you can use transform
in remember
to modify/pick parts of the path to use.
@lublak
This might also be useful if you need it outside of the prompt. That way it would be more modular.
I don't get these remarks.
Does file.save
have a text
argument that is the content of the file?
If so I can add a file
argument to commandvariable.transform
.
What would be the functionality of commandvariable.file.save
?
@rioj7 For me, it's perfectly adequate if it's prompt. But I've also thought a little further ahead if someone needs it to save the current file, for example.
"inputs": [
{
"id": "textTmpFile",
"type": "command",
"command": "extension.commandvariable.file.save",
"args": {
"text": "${file}",
"file": "${workspaceFolder}/.vscode/tmp-text.txt"
}
}
]
@lublak
This might also be useful if you need it outside of the prompt. That way it would be more modular.
I don't get these remarks.
Does
file.save
have atext
argument that is the content of the file? If so I can add afile
argument tocommandvariable.transform
.What would be the functionality of
commandvariable.file.save
?
A file
argument to the commandvariable.transform
would be the same solution yes :)
I was just thinking about how to build it so that it would be useful for more than just prompts.
Unfortunately I'm not a native speaker of English, so I have a bit of difficulty expressing myself. I'm sorry :/.
@lublak try v1.63.0
Only the transform
command has the saveToFile
property.
If you want to use any other command as file content you have to wrap it in a transform
and use variables.
An example input
:
{
"id": "saveToFile",
"type": "command",
"command": "extension.commandvariable.transform",
"args": {
"saveToFile": "${workspaceFolder}/.vscode/temp-text.txt",
"text": "${promptStringRemember:getContent}",
"key": "tmpfile",
"promptStringRemember": {
"getContent": {
"description": "What to store in the file",
"key": "fileContent"
}
}
}
}
@rioj7 works fine :) ty!
Currently in need an option to use promptStringRemember and save it to a file and get a filepath back. The debugger needs a file not a text input.
From the example, it would be useful to somehow receive the promptText as a tmpfilepath.