formulahendry / vscode-code-runner

Code Runner for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
MIT License
2.21k stars 298 forks source link

Support for CFML (ColdFusion) #214

Open bdw429s opened 6 years ago

bdw429s commented 6 years ago

VSCode is picking up adoption in the CFML community and I'm already seeing packages for frameworks like ColdBox MVC, TestBox BDD. and CFLint. What would it take to get support for running CFML from the VSCode coder runner package? We have a CLI tool called CommandBox that has a CFML REPL and also allows for command line execution of arbitrary files. No install is required for CommandBox, it's just a binary (Mac, Linux, and Windows all work, it just needs Java installed)

What are the integration points to be able to pass the code that needs run over to the CLI to run it?

cc/ @lmajano

formulahendry commented 6 years ago

Hi @bdw429s , you could refer to this PR #82 for the integration points.

There are two integration points:

Let me know if you have more questions.

evagoras commented 6 years ago

After a lengthy conversation in Slack with Brad, and trial and error, I got this code to work: "code-runner.executorMap": { "lang-cfml": "cd $dir && C:\\commandbox\\box.exe exec $fileName" } This has to be added to the File --> Preferences --> Settings JSON file.

It will run entire or partial CFM code in tags as well as in cfscript. When selecting a partial code, if in cfscript, you will need to also select the <cfscript>...</cfscript> part, otherwise it errors.

Other options params in the JSON are: "code-runner.runInTerminal": false // false runs in OUTPUT tab, true in TERMINAL, "code-runner.clearPreviousOutput": true // true clears the output tab for every run

The obvious problem with this is that the path to the BOX binary is totally dependent on the user's location, since there is no OS environment variable.

bdw429s commented 6 years ago

Thanks for posting that here @evagoras . I think we'll want to swap C:\\commandbox\\box.exe with just box so it's not Windows specific either and just make a note that users will need to have the box binary in their system path. Most of our non-Windows installation methods for CommandBox do this by default and we have instructions on the CommandBox installation help docs for doing it on Windows.

As for the settings, I'm not a VSCode user yet so I'm unclear on what the difference is between an output tab and a terminal. I'd say we'd mostly likely want to clear the screen, but it's hard to guess.

@formulahendry We have a few CFML packages out there already that have either cfml or lang-cfml mapped to .cfm and .cfc files already. Would it make sense to go ahead and use the executorMapByFileExtension setting in addition so the file extensions will still map even if the user doesn't have one of the other CFML packages installed?

formulahendry commented 6 years ago

For difference between an output tab and a terminal, if you have stdin, you need to use terminal. Otherwise, no obvious difference. Anyway, those setting have their default value. What you need to contribute is the executorMapByFileExtension or executorMap. @bdw429s You are right. Using executorMapByFileExtension makes more sense.