Copas, Delphi script for Shell
Have you ever wished that there was some way to script the shell without resorting to archaic batch files, python or any of the other weird languages out there? Well, a while back I started to implement a special version of DWScript (Delphi web script) which does exactly that. It allows you to execute DWScript files directly from the shell powered by a rich set of OS level functionality.
I havent come up with a cool name for it yet so i dubbed it copas, short for “command-line object pascal”. Since DWScript is the parser engine we use with Smart Mobile Studio, the dialect is identical – and you can even use some of the Smart Pascal classes with it (no web-engine stuff naturally).
If someone updates the DWScript repository for FreePascal to the latest, we can kiss python, node.js and all the other odd-ball scripting engines for shell/bash goodbye!
Why is this cool?
Being able to execute pascal scripts is not the hard part (since that is already covered by DWScript), the hard part is providing classes that allows you to interact with the operative system. Things like file creation, pipes, executing applications, service rights — these are not complex but rather time-consuming tasks.
Since time is not something I have these days, it will take some time before I release any source-code for this, but perhaps over Xmas I’ll have time to finish it. I started on this months ago but havent had time to do much work on it. But streams and a pipe client (for windows) is already in place. The plan is to compile with FireDAC (or morpheus) so you can connect directly to all major DB engines, create databases on the fly, copy data between engines, perform backup tasks with ease — well, the possibilities are endless and only limited by time and imagination.
But the benefits should be obvious:
- creating scripts that deals with files and folders can now be done in a language you know and love
- Full OOP support, including partial classes, interfaces and all the cool stuff Smart Pascal is currently offering
- Script servers (REST, WebSocket etc)
- Add smart mobile studio and you have a fully object pascal driven infrastructure.
- Perfect for automation tasks
Well, no time to complete this now – but after Xmas I’ll share out the SVN repo.