{"id":18360531,"url":"https://github.com/fboender/sla","last_synced_at":"2025-08-23T06:03:40.146Z","repository":{"id":143302652,"uuid":"158283426","full_name":"fboender/sla","owner":"fboender","description":"The Simple Little Automator","archived":false,"fork":false,"pushed_at":"2023-09-12T09:15:14.000Z","size":142,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-23T06:03:17.567Z","etag":null,"topics":["build-script","build-system","build-tool","builder","make","makefile","task-runner"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fboender.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-19T20:07:33.000Z","updated_at":"2024-06-24T00:13:49.000Z","dependencies_parsed_at":"2024-11-10T05:01:41.666Z","dependency_job_id":null,"html_url":"https://github.com/fboender/sla","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/fboender/sla","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fboender","download_url":"https://codeload.github.com/fboender/sla/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboender%2Fsla/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271745659,"owners_count":24813515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-script","build-system","build-tool","builder","make","makefile","task-runner"],"created_at":"2024-11-05T22:28:44.249Z","updated_at":"2025-08-23T06:03:40.097Z","avatar_url":"https://github.com/fboender.png","language":"Shell","readme":"# sla - Simple Little Automator 🥗\n\nTired of Make's moronic syntax and rules? Not working on a project that\nrequires incremental compilation? 😭 when you need to install 2.4\nGiB of Ruby dependencies for a simple build system? Want to be able to execute\nsimple build rules from anywhere in your project tree? Then `sla` is for you!\n\nsla is the Simple Little Automator. It's a tiny shell script that invokes\nshell functions found in a `build.sla` script in your project's root dir. It\nis ideal for smaller projects and projects that don't require compilation,\nsuch as scripting languages.\n\n![](https://raw.githubusercontent.com/fboender/sla/master/screenshot.png)\n\n## Why?\n\nEvery task running / build system I've researched is either for a specific\nlanguage, too large or complicated or uses declarative style build rules.\nDeclarative rules are very limited in their capabilities. It's often not even\npossible, or very awkward, to do loops. This immediately leads to the\ncreation of helper shell scripts. The build tool then becomes nothing more\nthan a wrapper around those scripts. So why not use shell scripts right away?\nThat's what Sla does.\n\nUsing shell scripting has several benefits:\n\n* It's not limited to a single language. Most projects don't just need to\n  compile code. They also need to setup projects, run tests, generate\n  documentation, etc. Interpreted languages don't require incremental builds\n  at all, making most build systems' core functionality useless.\n* It's cross-platform, so it will run everywhere.\n* It's powerful. You can script basically anything.\n* You don't even need Sla installed. You can run build rules directly through\n  the shell. Sla is just a simple convenient wrapper.\n* It's easy to call other build systems such as Make through sla, so we don't\n  lose any functionality such as incremental builds.\n\nAdditionally, Sla has some benefits of its own:\n\n* It allows you to list the available rules, something Make still can't do\n  properly after 43 years.\n* You can include short and long descriptions / help for build rules.\n* You can run target rules from anywhere in your project.\n* Sla automatically times your builds.\n\n## Installation\n\nYou can install `sla` with itself from the repo.\n\nSystem-wide:\n\n    git clone https://github.com/fboender/sla.git\n    cd sla\n    sudo install -m 755 sla /usr/local/bin\n\nJust for your user:\n\n    git clone https://github.com/fboender/sla.git\n    cd sla\n    install -m 755 -D sla ~/.local/bin\n    \nFor the above to work, you should have `~/.local/bin` in your PATH.\n\n## Usage\n\nHere's the output of `--help`, although there's not much to see:\n\n    Usage: sla [-hdv] [--version] \u003crule\u003e [param [param...]]\n\n    Simple Little Automator. Find and execute tasks from a shell script.\n\n    Arguments:\n      -h, --help      Show this help message\n      -d, --debug     Show debug information\n      -v, --verbose   Verbose output\n      -V, --version   Show sla version\n\n    If no \u003crule\u003e is specified, lists the available rules.\n\n    Use 'sla \u003crule\u003e --help' to show a rule's full description.\n\nYou can use the `--verbose` option to show what your rules are executing.\nBasically the same as doing `set -x` in your script.\n\n### Example usage\n\nHere's an example of running `sla` with the `test` rule:\n\n    ~/Projects/my_project/src/llt/ $ sla test\n    ./src/tools.py:25:80: E501 line too long (111 \u003e 79 characters)\n    Exection of rule 'test' failed with exitcode 2. Duration: 0h 0m 1s\n\n`sla` searches up the current path until it finds a `build.sla` file, changes\nto that directory, sources it in the shell, and executes the requested shell\nfunction. Here's what the `build.sla` file for the above 'test' rule might\nlook like:\n\n    ~/Projects/my_project/src/llt/ $ cat ../../build.sla\n    #\n    # This is a script containing functions that are used as build rules. You can\n    # use the Simple Little Automator (https://github.com/fboender/sla) to run\n    # these rules, or you can run them directly in your shell:\n    #\n    #   $ bash -c \". build.sla \u0026\u0026 test\"\n    #\n\n    clean () {\n        # Clean artifacts and trash from repo\n        find ./ -name \"*.pyc\" -delete\n        find ./ -name \"*.tmp\" -delete\n    }\n\n    test () {\n        # Run some code tests\n        clean  # Depend on 'clean' rule\n        flake8 --exclude src/llt --ignore=E501 src/*.py\n    }\n\nAs you can see, build rules are just plain old shell functions. Sla used bash,\nwhich should be available just about everywhere.\n\nCreating dependencies on other rules is as simple as calling it as a normal\nshell function.\n\nYou can list available rules by simply omitting a rule name:\n\n    $ sla\n    Available rules:\n      - doc: Generate documentation\n      - clean: Clean artifacts and trash from repo\n      - test: Run some code tests\n      - install: Install the program\n\nFunctions that start with an underscore ('`_`') are not shown.\n\n### Documenting rules\n\nComments at the start of a function / rule definition are parsed as\ndocumentation. Take the following rule definition for example:\n\n    install () {\n        # Install sla \n        # Install sla to $PREFIX (/usr/local by default).\n        #\n        # You can specify the prefix with an environment variable:\n        # \n        #     $ PREFIX=/usr sla install\n\n        # Set the prefix\n        PREFIX=${PREFIX:-/usr/local}\n        DEST=\"$PREFIX/bin/sla\"\n        env install -m 755 ./sla \"$DEST\"\n        echo \"sla installed in $DEST\"\n    }\n    \nIn this case the first line is the short description. It is shown when listing\nthe rules. The rest of the comments, up to the empty line, are shown when\nrequesting a rule's documentation with `sla \u003crule\u003e --help`. For example:\n\n    $ sla install --help\n    install: Install sla\n        \n         Install sla to $PREFIX (/usr/local by default).\n        \n         You can specify the prefix with an environment variable:\n         \n             $ PREFIX=/usr sla install\n\n### Running rules without `sla`\n\nSince `sla` rules are just plain old shell functions, you don't even need\n`sla` installed to run them!:\n\n    ~/Projects/my_project $ bash -c \". build.sla \u0026\u0026 test\"\n    ./src/tools.py:25:80: E501 line too long (111 \u003e 79 characters)\n\nThat's useful so that people don't need to install the build system you prefer\njust to do a `make install`.\n\n### Passing values\n\nYou can pass values as environment variables:\n\n    $ export TARGET=/usr/local\n    $ sla install  # installs in /usr/local\n\nor\n\n    TARGET=/usr/local sla install\n\nYou can also pass command-line arguments:\n\n    sla install /usr/local\n\nThese become available as normal positional arguments in a rule / shell\nfunction:\n\n    install () {\n        TARGET=$1\n    }\n\n### Dependencies\n\nCreating dependencies is as easy as calling a shell function. In the following\nexample, the `test` rule depends on the `lint` rule and the `unittest` rule:\n\n    lint () {\n        # Scan code for common problems\n        flake8 src/*.py\n    }\n\n    unittest () {\n        # Run all unit tests\n        cd src/\n        nosetests\n    }\n\n    test () {\n        # Run all tests\n        lint\n        unittest\n    }\n\nIf a dependency only needs to be executed once (such as `clean` rules), just\nset a flag in the rule. For example:\n\n    clean () {\n        if [ -z \"$CLEANED\" ]; then\n            echo \"Cleaning\"\n            # Your cleaning instructions here.\n            CLEANED=1\n        fi\n    }\n\n\n### Flags\n\nSla sets various flags when running. For example, if the user runs `sla -v`\n(verbose), the `FLAG_VERBOSE` flag is set to `1`. You can use this in your\nbuild scripts:\n\n    if [ \"$FLAG_VERBOSE\" -eq 1 ]; then\n        echo \"Additional info\"\n    fi\n\nor\n\n    [ \"$FLAG_VERBOSE\" -eq 1 ] \u0026\u0026 echo \"Additional info\"\n\nThe following flags are set:\n\n* `FLAG_DEBUG=1`: Show internal sla debugging info\n* `FLAG_VERBOSE=1`: Show build rule execution debugging info\n\n### Disabling strictness\n\n`sla` will stop running as soon as a command returns a non-zero exit code. You\ncan turn this off by wrapping a block of code with `set +e` statements:\n\n    set +e\n    # these commands won't cause Sla to stop if their exit codes are != 0\n    rm nonexisting\n    set -e\n\n### 'install' rule\n\nIf you have a rule called \"install\", and you also want to use the `install`\nunix tool to install software, you'll end up with an endless loop, unless you\nspecify that you want to use the system's `install` and not the shell function\nyou just wrote. You can use `env` for that:\n\n    install () {\n        env install -m 755 ./sla \"$DEST\"\n    }\n\n### Bash Autocompletion\n\nTo get auto completion for bash, put in your `~/.bashrc`:\n\n    # Complete sla rules\n    _complete_sla_rules()\n    {\n        COMPREPLY=()\n        cur=\"${COMP_WORDS[COMP_CWORD]}\"\n        comp=$(sla 2\u003e/dev/null | grep \"^ -\" | sed \"s/^ - \\([^:]*\\).*/\\1/\")\n        COMPREPLY=( $(compgen -W \"${comp}\" -- $cur))\n        return 0\n    }\n    complete -F _complete_sla_rules sla\n\n### Automatic execution of rules\n\nYou can use a tool like [entr](http://entrproject.org/) to automatically\nexecute rules when files change:\n\n    $ find ./ -name \"*.1.md\" | entr sla doc\n    Converting sec-diff.1.md\n    Execution of rule 'doc' succeeded with exitcode 0. Duration: 0h 0m 0s\n\nThe `doc` rule converts a Markdown file to a manual page. `entr` watches all\nchanges to `*.1.md` files in the project, and if any of them change, it\nexecutes `sla doc` to regenerate all man pages.\n\n## License\n\nsla is licensed under the MIT License:\n\n    Copyright (c) 2022 Ferry Boender\n\n    Permission is hereby granted, free of charge, to any person obtaining a\n    copy of this software and associated documentation files (the \"Software\"),\n    to deal in the Software without restriction, including without limitation\n    the rights to use, copy, modify, merge, publish, distribute, sublicense,\n    and/or sell copies of the Software, and to permit persons to whom the\n    Software is furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n    DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboender%2Fsla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffboender%2Fsla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboender%2Fsla/lists"}