Extending Linux and Mac with C#

In the following video I play around with a simple Console application, which allows me to evaluate Lizzie snippets, which I again extend with C# methods. This allows me to create cross platform daemons and shell extension scripts, that can be evaluated in a Mac, a Linux machine, or a Windows machine. Since Lizzie is a scripting language, it also allows me to dynamically change whatever my snippets do, and use the same “host” for multiple scripts.

You can find the code I am using beneath the video. My personal use cases ranges from build scripts, to all sorts of automated jobs, where I need to do more complex stuff than what a simple bash script allows me to do. The additional benefit of course is that my scripts are cross platform. Expanding upon the code to allow for it to take multiple files, would obviously be easy.

Here is the code I ended up with as I wrapped up the video …

using System;
using System.IO;
using lizzie;

class MainClass
    [Bind(Name = "write")]
    object WriteLine(Binder<MainClass> binder, Arguments arguments)
        return null;

    [Bind(Name = "read")]
    object ReadLine(Binder<MainClass> binder, Arguments arguments)
        return Console.ReadLine();

    public static void Main(string[] args)
        // Figuring out file caller supplied
        if (args.Length != 1) {
            Console.WriteLine("*     Add a filename you want to evaluate as an argument     *");
        var filename = args[0];
        using (var reader = new StreamReader (File.OpenRead(filename))) {
            var lambda = LambdaCompiler.Compile(new MainClass(), reader.ReadToEnd());

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.