Hacker News new | ask | show | jobs
by snake_case 1214 days ago
Nice to see other markdown-based task runners!

I'm the creator of mask which is another alternative, written in Rust. Our approaches slightly differ. It looks like xc parses the README.md file for commands while mask looks for a maskfile.md by default, though you can provide a --maskfile arg to specify any markdown file that follows the expected format.

https://github.com/jacobdeichert/mask

2 comments

Why not a simple well commented shell script?

Most code editor will syntax highlight it a lot better.

In the docs for iommi we've tried both the documentation-centric and the code-centric approaches.

We started with the documentation-centric approach because we had a lot of documentation and wanted to check if the code examples in them worked. So I wrote a bad parser that extracted the code from rST and put them into python files that we then ran. This worked... ok-ish.

Then we switched to the code-centric approach that we use today where we write tests that we generate the documentation from. There are specially marked documentation strings plus some tags for parts of the tests that shouldn't be included in the generated documentation, and some other cool little features like saving down the output of test requests to their own html files and then embedding them with iframes instead of using screenshots.

I am a programmer so I like the code-centric approach more, but they are pretty similar. The big thing is that you need to control the file format/parser yourself.

Before mask, I used a custom bash command runner which relied on a directory structure to implement the command and subcommand tree. This was pretty simple and nice to use. So if it’s working for you, there’s no reason to look for alternatives.

Mask takes advantage of the markdown structure in a few ways. Headings define top-level commands and subheadings represent nested subcommands, which makes it extremely easy to structure a command tree. Also, mask checks the code block lang code (ruby, python, js, fish, etc…) and executes the script using that runtime as long as you have it installed. There’s other features, but those two are great examples why markdown works well as a command definition format.

> Most code editor will syntax highlight it a lot better.

Really? I thought most now understood markdown code blocks with language tag?

Let me ask a silly question.

Use case, I'm on Mac OS X (aka not Linux, not Windows). I have an Apple M1 processor (aka not x86_64). I have 8GB of RAM (silly mistake on my end, I know). Therefore, Docker + virtual machine based solutions are too expensive memory wise.

However, I also like to think in terms of "let me separate this functionality into say... a Kubernetes workload like a pod"

There's no good containerization solution for Mac OS.

Can something like `mask` be used to achieve basically a "poor man's k8s" for a long running service?

Basically, run these 5 or 6 services in parallel, let me be able to see their logs individually.

If not, I completely understand. I just can't tell if there is an actual need for a solution like this, if it already exists and I just can't find it, etc.

Mask can't directly solve this problem by itself, it just runs whatever script you give it. If you can write a python/js/bash/etc script to achieve what you want, you can stick it inside a maskfile with the rest of your commands.

Regarding docker, I haven't tried it on M1 yet. However, I've been using Ubuntu multipass [1] for over a year now and I'm very happy with it. It makes it easy to set up and manage VMs for different projects, and it seems to run very efficiently on macOS in my experience. When a project needs a docker container like postgres, I just run docker compose inside the VM rather than running it directly in macOS. You can also limit the amount of CPU/RAM the VM uses to keep things under control.

[1]: https://github.com/canonical/multipass

Have you tried using a process manager like supervisord[1] or pm2[2]? The former has a pretty clean declarative interface that you could view as a replacement for something like a docker-compose file or a k8s pod config.

You don't get any containerization/isolation benefits obviously, but it sounds like you've already accepted that.

[1] http://supervisord.org/ [2] https://github.com/Unitech/pm2

Foreman is a nice, easy to use local process manager. It's what heroku and such use with a simple Procfile for defining multiple processes, but it would work fine for running multiple developer tools, testing services/dependencies, etc.

There are multiple implementations of it, heres the canonical one: https://github.com/ddollar/foreman And heres a go version that's easier to install and use: https://github.com/ddollar/forego

And another possibly lighter alternative is something like concurrently: https://github.com/open-cli-tools/concurrently