Jedi Code Formatter CLI
I took Jedi Code Formatter (JCF) from Lazarus IDE repository and made it as CLI (command line interface) version by removing all the GUI (graphical user interface) parts from the original GUI version. The CLI version can be used as Pascal code formatter in Visual Studio Code, or as backend engine of an online Pascal code beautifier.
jcf-cli
GitHub repo into your own folder.jcf.lpi
project within jcf-cli/CommandLine/Lazarus
folder.JCF
file from jcf-cli/Output/Lazarus
folder along with the jcf.xml
configuration file../JCF -?
command. It should show the usage manual.jcf-cli
GitHub repo into your own folder.jcf.lpr
project within jcf-cli/CommandLine/Lazarus
folder.test.pas
file from jcf-cli
folder.JCF
program using Tasks → Run Task... → JCF: Test CLI Program menu and you should see the result in the test.pas
file.Note: I've included the executable file for Linux, Mac, and Windows in
Output/Lazarus
folder so you don't need to build it yourself. However, it's not guaranteed using the latest modification. 😊
JCF
and jcf.xml
config files into your Pascal workspace folder.tasks.json
if you already have one.tasks.json
file.{
"label" : "JCF: Beautify Code",
"type" : "shell",
"command": "./JCF",
"args": [
"${file}",
"-clarify",
"-inplace",
"-config=jcf.xml"
],
"presentation": {
"reveal": "never"
},
"problemMatcher": []
},
-clarify
arg into -obfuscate
.tasks.json
. Now you should have new JCF's tasks in your tasks list.Although JCF is a good Pascal code formatter, it has one single problem that quite annoying. JCF requires the code must be compilable which means it has to be a complete program and syntactically correct. JCF will fail on code snippets or wrong code. To make it works on code snippet, it must be put between a begin..end
pair and has a correct program
header, like this:
program test;
begin
// put code snippet here
end.
Here's JCF CLI in action within VS Code (with OmniPascal):
Note: If you're also interested in my other tasks shown in the demo, see my gist about it here.
Hope it's gonna be useful to other Pascal fellows out there. Have fun! 😊