Project Description

GNU Make has been a popular software tool used for automating simple build, test, and general source code management tasks for a long time. You'll find Makefiles in many software repositories – we use it on many projects as SUSE! For the most part, Make does its job, but often what people want to do with it is not exactly what it was designed for. Specifically, Make users often use Makefiles as a means a means of building out a set of commands that can be applied to their repository. But therein lies the problem: Make was not designed to build quick command line utilities at all, and it quickly becomes a nightmare as soon as the user wants to include arguments or options in their commands. The common alternative is simply to build out a tangled mess of build scripts.

Cast aims to provide a hybrid solution by letting users declare commands with well defined options and arguments that can execute using any language of their choosing via a simple plugin interface. Essentially, Cast is a flexible build tool and a programming language designed to trivialize the process of defining and executing commands for repository management.

Goal for this Hackweek

Build out a basic version of Cast where users can declare commands with arguments and options that compile to Shell code that is invoked when users run cast commands.

Resources

Here's a simple example of what a Castfile might look like:

# A very basic command. Runs "go mod tidy".
tidy:
    go mod tidy

# The build command. Builds Go source code.
# Cast commands will be compiled to Shell functions.
build(
    # Optional argument "path". 
    # Represents the path to the package or file to compile. 
    # Defaults to ".".
    path: Path? .,
    # Whether to build in debug mode. Defaults to false.
    -d | --debug: Bool? false,
    # The path where the resulting binary should be placed.
    -o | --out: Path?,
):
    # The script is written in Shell, but can also be templated using Tera
    # See https://keats.github.io/tera/docs/.
    go build {% if debug %} -gcflags=all="-N -l" {% endif %} {%if out.is_set %} -o $out {% endif %}

# The run command. Builds and runs the server.
run(
    # Required argument "host".
    # Falls back to SERVER_HOST envvar if this argument is not passed.
    host | env$SERVER_HOST: Any,
    # The optional port number to bind to.
    # Defaults to 8080.
    port: Number? 8080,
    # Whether to run in debug mode. Defaults to false.
    -d | --debug: Bool? false,
):
    # Call the build function defined above (it will be compiled to Shell and
    # can therefor be called like any Shell function).
    build -o bin/server

    # Run the server. Argument and option values will be available both as Tera
    # template values and as Shell variables.
    ./bin/server {%if debug %} --debug {% endif %} $host $port

A user could invoke the run command using this Castfile as follows: cast run myhost 8443 --debug

Looking for hackers with the skills:

Nothing? Add some keywords!

This project is part of:

Hack Week 23

Activity

  • 6 months ago: flonnegren liked this project.
  • 6 months ago: epaolantonio liked this project.
  • 6 months ago: gleidi liked this project.
  • 6 months ago: bbachmann started this project.
  • 6 months ago: bbachmann originated this project.

  • Comments

    Be the first to comment!

    Similar Projects

    This project is one of its kind!