ZmanimCLI (Command Line Interface)

Moshe Wagner who wrote the Zmanim GUI notified me in August that that he created a command line interface for zmanim using my Zmanim API. The technical approach of using reflection was similar to the way I used reflection in the Zmanim Clock Applet, but he took it to new heights. Sample use of accessing zmanim using his CLI interface is:

moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar sunrise
6:10:28
moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar --date 2010/08/12 tzais72
20:38:15
moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar
Usage: ZmanimCLI [options] [Time]

Options:
       -d      --date <yyyy/mm/dd>             Set date. (Year first!)
       -lat    --latitude <latitude>           Set location's latitude
       -lon    --longitude <longitude>         Set location's longitude
       -e      --elevation <elevation>         Set location's
elevation; Positive only
       -tz     --timezone <timezone>           Set location's TimeZone

Help:
       -h      --help                          Show this help
       -stl    --time-list                     Show common available
times to display
       -ftl    --full-time-list                Show all available
times to display
       -tzl    --timezone-list                 Show available timezones

Example:
       ZmanimCLI --latitude 31.7780 --longitude 35.235149 --elevation
600 --timezone Israel Sunrise
       Will show the sunrise time today in Jerusalem

While your first reaction may be that it is interesting in a theoretical geeky way, but has no practical value, I will quote Moshe’s explanation as to why it is useful:

Why is this useful? Well, first of all it was a nice experiment. But mainly, you can now use Zmanim (although externally), via any language you want, no longer being tied to Java.

Months later, Moshe actually put this to practical use in his C++ based Luach project. This Luach (similar to the known Kaluach) uses the Qt framework. utilizing libhdate for the date stuff (something not offered by the Zmanim API, and the topic of a future Zmanim API FAQ), displaying zmanim using the Zmanim API via CLI for the zmanim calculations. While you would expect such an approach to be slow, using the Luach seemed almost instantaneous. I will post more about his Luach program (recently reviewed at KosherDev.com) at some point in the future.

4 thoughts on “ZmanimCLI (Command Line Interface)”

  1. Another use for this is to make a simple CGI interface, such as to interface with http://www.textmarks.com for SMS zmanim. (Currently I don’t have this running because I don’t have easy access to a web server with CGI enabled and Java.)

    I also wrote code similar to this – look here for the source code. It uses a lot of the architecture from elsewhere in ZmanimBot code to do stuff, which makes it more complicated than would really be necessary for many purposes, but it does add in the parsing and additional info that ZmanimBot provides.

    P.S. Why is my browser making requests from http://www.gravatar.com anytime I type a character in the comment field? It’s kinda annoying…

  2. Michael,
    Thanks for your comment. It is interesting that you implemented and found an alternative use for a CLI interface to the API. I do not think I was aware of your implementation, thought I may have forgotten about it since posting about your ZmanimBot quite a while ago. Has there been any news on the bot since that time?
    As far as the Gravatar lookup, the Live Comment Preview plugin meant to allow you to preview your post, seems to be the cause, and seems to need some work.I will try and see if I can find a solution.

Leave a Reply

Your email address will not be published. Required fields are marked *