Open weinand opened 5 years ago
My use case would be to use the path to the current file as the default value for one of my inputs
.
"inputs": [
{
"id": "which-file",
"description": "Enter the path to a .py file",
"default": "${file}",
"type": "promptString",
}
]
It would be very helpful, to be able to pass a list of strings to the "pickString" input. This would allow the usage of variable number of strings.
set myStrings="s1", "s2", "s3"
"inputs": [
{
"type": "pickString",
"id": "str",
"description": "Choose string...",
"options": [${env:myStrings}],
"default": "s1"
}
]
This would definitely be useful to have as there are plenty of use cases for which this is handy. Why is this not supported in the first place, what is the rational?
To avoid recursion and sequencing problems.
Are there any workarounds? i.e. any way to have a variable input default?
As noted above, while variable substitution appears to work (at least with the extension I'm using), the prompt and resulting command line are non-intuitive.
@mdeggers
As noted above, while variable substitution appears to work (at least with the extension I'm using), the prompt and resulting command line are non-intuitive.
Can you give an example of a variable substitution that works for you? For me, no substitutions work.
I'm using DeltaXML's XSLT/XPath extension, and I've created the following task:
{ "version": "2.0.0", "tasks": [ { "type": "xslt", "label": "Basic XSLT", "saxonJar": "${config:XSLT.tasks.saxonJar}", "xsltFile": "${input:xslFile}", "xmlSource": "${input:srcFile}", "resultPath": "${input:outFile}", "group": { "kind": "build" }, "problemMatcher": [ "$saxon-xslt" ] } ], "inputs": [ { "type": "promptString", "id": "xslFile", "description": "XSLT file name", "default": "${fileBasenameNoExtension}.xsl" }, { "type": "promptString", "id": "srcFile", "description": "SRC file name", "default": "${fileBasenameNoExtension}.xml" }, { "type": "promptString", "id": "outFile", "description": "Output file name", "default": "./xslt-out/${fileBasenameNoExtension}" } ] }
The "default" doesn't work,, in that I still get ${fileBasenameNoExtention} as the default.
When I run the command, I still see the unsubstituted values:
Executing task: D:\Programs-x64\Java\jdk-11.0.11+9-jre\bin\java.exe -cp D:\Programs\saxon\saxon-he-10.3.jar net.sf.saxon.Transform -xsl:${fileBasenameNoExtension}.xsl -s:${fileBasenameNoExtension}.xml -o:./xslt-out/${fileBasenameNoExtension}.html
However, if I have greeting.xsl open, the XSL file used is greeting,xsl, the source file used is greeting.xml, and once I add .html to the output, I get greeting.html as expected.
@mdeggers
As noted above, while variable substitution appears to work (at least with the extension I'm using), the prompt and resulting command line are non-intuitive.
Can you give an example of a variable substitution that works for you? For me, no substitutions work.
Is there any update on this? Is this planned for the future or officially not being supported?
@mdeggers As of January 2022 DeltaXML's XSLT/XPath extension has commands for getting task file-paths. You may therefore not need to use the Task inputs property. The user is presented with a 'QuickPick' list of recently used files or the option to trigger the relevant 'File Open' or 'File Save' dialog - as shown below:
As well as specialist XSLT commands for picking xslt, input-xml and result-xml, there's also a general purpose 'pickFile' command that takes a configuration argument and therefore does need to be defined in the 'inputs' property.
testing #64214:
I assume that variable substitution in the "inputs" section is disabled to avoid recursion...
However, I think it would be helpful to allow "simple" non-interactive variables like ${env:...}, ${config:...}, ${workspaceFolder:...}. This makes it possible to do something like this: