I am almost finished with the 6th week of my GSoC and for this week`s blog post, I would like to briefly talk about command line handlers, clap and why is it important.
Pharo has various command line handlers for various situations. Few of them are
A list of all such installed handler can be retrieved using the command
./pharo Pharo.image --list from a terminal.
Each of the above handlers is used in different situations and each has a different use.
- st is used to load and execute source files of type .st. The code can be run with or without quitting the image,
- Fuel is a general purpose object serialization framework for Pharo. This Fuel handler is used to load all such fuel files.
- config handler enables installing Metacello configurations from the command line and also has the option for inspecting the versions, listing all the versions.
- The save handler is used to save the image file and changes file under a new name.
- test handler is a command line test runner.
- update handler is used to update the image to the latest version.
- printVersion handler is used to print the version of the image. Similar to the ‘System Reporter’. The output is printed in an easy to parse format.
- The eval command line handler reads a string from the command line and outputs the evaluated result and will quit the image.
And what is Clap. Clap stands for ‘Command Line Argument Parsing). Clap-st is a new command line parser for Pharo which is still in development. This was inspired by clap-rs. And What makes clap different from other command line handlers? Clap enables an application programming interface like framework for application-specific command line behaviors. It helps in creating specific commands, configuring how the match should happen, etc. This will be very helpful in writing scripts in Pharo for which the packages in Pharo can be used through clap. To give an insight into how clap would be helpful, for example, there is a command ‘X’ which will call a class from a package. But the X has different results, then the concept of flags come into play. I can have different flags for different results. So, depending on the flag I give I get the desired output. When writing scripts, this will come in very handy.
Currently, clap is still in initial stages. But, the basic outline of clap is like this. It has three main classes in its core package ClapCommand, ClapFlag and ClapPositionals. ClapCommand will correspond to the unix command, flags, positionals and subcommands. Here positionals refer to the positions of the commands and flags in a given input. ClapFlag corresponds to the flags in the input given. Flags will be recognized in two forms long and short. ClapPositionals correspond to the input commands other than the flag. To test the clap-st package Mocketry package is used as of now. This is a very cool package. Do check it out. This link will give a good understanding of mocketry.
This is just an introduction post to the clap-st in Pharo. I will make an elaborate post on this soon. Do post your comments or feedback.