I'm pleased to officially announce the release of version 1.3 of command-line MiniScript! This is also the first release of the latest and greatest version (1.6.2) of the core MiniScript language.
Command-line MiniScript has been getting a lot of love in the community lately; some users are using it daily in their work. Let's look at what's new!
exec
The biggest new feature in 1.3 is the addition of an exec
function, which lets you run a system command. exec
takes a command to run, such as "ls -la" on Linux/Unix or "dir" on Windows, and an optional timeout. If not specified, the timeout defaults to 30 seconds, which should be more than plenty for most system commands.
The result is a little map containing three entries:
- status: the result code of the command, which is usually 0 for success and some nonzero value for failure.
- output: whatever the command sent to the stdout stream, i.e., normal output.
- errors: whatever was sent to the stderr stream, that is, error output.
With this new ability, your MiniScript scripts can do anything you could do (technically, limited by whatever ownership/permissions the script has) on the command line. Here are just a few ideas of how that might be applied:
- run a database migration tool
- send an email
- launch or terminate a service (e.g., a web server)
- clean up log files
- remote-copy files with scp or rsync
- send a command to a remote machine with ssh
- zip or unzip files
- search for files with fgrep
The possibilities are endless. Almost anything you could do with (say) a bash script, you can now do in your favorite language (I'm talking about MiniScript here) too!
Fixed output-buffering issue
In the previous release of command-line MiniScript, there was a problem if you suppressed the line break after print
and then followed it with input
, like this:
print "Your name", ""
name = input("? ")
Granted, this example is contrived, because you'd probably just put the whole prompt inside the argument to input
. But there were real-world cases where, in more complex code, something like this was wanted, and it didn't work properly; the output from the print
would appear only after you'd typed your response to the input
.
So that's fixed now.
New "-i" option
Thanks to community member Marc Gurevitx, you can now invoke MiniScript with a -i
option to drop into interactive mode (i.e. the REPL) after running a script.
This can be handy when your script does some initial setup or testing, and you want to follow that with some interactive exploration. Also handy for debugging, as once the script is finished, you can examine the state of global variables (like age
in the screen shot above).
New/improved library modules
The standard import modules in the lib folder have been updated. These include new functions in listUtil
and stringUtil
, and a whole new importUtil
library (familiar to Mini Micro users, but new to command-line MiniScript).
Also, the vt
module, providing easy access to ANSI terminal escape sequences, has been updated. It now supports setting the foreground and background color of the text!
With these, you can make much more interesting and dynamic command-line applications.
New "demo" folder!
For the first time, the command-line MiniScript distribution includes a demo
folder, with some sample MiniScript programs. These are especially great for new users, who may want to quickly see what MiniScript code looks like. As such, they span the range from trivial to complex:
-
countdown: a tiny demonstration of
print
andwait
. -
dogYears: a very small program that demonstrates
while
,input
,val
, andif
/else if
. - acey-deucey: a little betting game. How much virtual money can you make before you go bust?
- therapist: our own miniature version of ELIZA; kind of overshadowed by modern LLM-based chatbots, but still interesting as an example of advanced string processing.
- textAdventure: a short but challenging text adventure game called "The Greedy Gargoyle".
- superstartrek: a port of a classic BASIC game from the late 1970s, now updated and running on your terminal in technicolor!
Language Improvements
As mentioned at the top, command-line MiniScript 1.3 also includes core language 1.6.2, the very latest and greatest version of the MiniScript engine. These include some nice improvements:
- better error messages in several cases
- miscellaneous bug fixes
-
intrinsics
, a map containing all the intrinsic methods
Get Command-Line MiniScript Now!
You can download MiniScript for the command line from:
https://miniscript.org/cmdline/
As always, MiniScript is free. While you're there, use the links on the home page to download the manual, find some books about it, or join the community. We're a very friendly bunch and always happy to welcome new members!
And finally, consider this. With easy access now to terminal colors, cursor positioning, etc., you can make a colorful and engaging game entirely with command-line MiniScript. And there is a project coming that will allow you to publish such a game on the web, running entirely in the browser -- no server needed. So! What do you think of the idea of a command-line MiniScript game jam? Share your thoughts in the comments below!
Top comments (0)