8 ms·
Show HN: Makedown – A Markdown powered Makefile alternative
`makedown` allows you to organise your shell scripts in one or several markdown
files, by mix and matching different scripting languages for various commands
and needs.
zsh/bash/sh, python, javascript or anything else available on your system.
Handy for replacing one-line-based package.json scripts or shell-based
Makefiles.
One can also write documentation and explanations to various commands in the same
`.md` file.
Most editors highlight correctly most languages in the markdown code blocks,
even when you use several scripting languages.
Here is a demo .md file https://github.com/tzador/makedown/blob/main/DEMO.md https://github.com/tzador/makedown/blob/main/DEMO.md
More information available in the
https://github.com/tzador/makedown/blob/main/README.md https://github.com/tzador/makedown/blob/main/README.md
Provided the following `example.md` in the root of your project,
the defined commands are available to run from any of the projects subfolders:
--- Start of example.md ---
# hello
Prints "Hello" to `stdout` using Zsh.
```zsh
echo "Hello"
```
# world
Just prints "World" to `stdout` using JavaScript.
```js
console.log("World");
```
# weather-tomorrow
Prints the weather for tomorrow to `stdout` using Zsh.
```zsh
curl wttr.in/tomorrow
```
# generate-password
Prints a random password to `stdout` using Python.
```python
import random
import string
length = 16
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
print(password)
```
--- End of example.md ---
You can run any of the commands from anywhere in the project,
just by typing `makedown a-command-name` or a shorter `m a-command-name`.
$ makedown --help
hello - Prints "Hello" to `stdout` using Zsh.
world - Just prints "World" to `stdout` using JavaScript.
weather-tomorrow - Prints the weather for tomorrow to `stdout` using Zsh.
generate-password - Prints a random password to `stdout` using Python.
$ makedown hello
Hello
$ makedown world
World
$ m weather-tomorrow
Sunshine # prints more details actually
$ m generate-password
4444444444444444
$ m generate-password --help
Prints a random password to `stdout` using Python.
The commands have simple syntax, they start with a header with a link and stop
when the next header starts.
Like so:
# [a-command-name]() A short description.
Some documentation.
```bash
some command
```
You can use other interpreters, like `python`, `node`, `ruby`, etc.
You can also use a custom interpreter specified using hashbang, like:
# [run-deno-script]() Runs a script using the Deno interpreter.
Deno has to be installed on your system.
```typescript
#!/usr/bin/env deno run
const message: string = "hello, world";
console.log(message);
```
All the .md files in the current directory and all the parents are examined
when looking for commands.
Would be very grateful for any suggestions or other feedback.
Thank you.
- djbusby 2y agoX is kinda overloaded. Maybe "makedown"? Or something? I just do mine in bash (make.sh) and it runs scripts from make.d/ which are in whatever (python, js bash, PHP)
- nunobrito 2y agoMakedown is a good name. +1 vote from me (in case it counts)
- timz 2y agoLove the makedown name, renaming.. As for a short name available in terminal, we can add alias m="makedown" as part of zsh completion script. Both: $ makedown deploy-to-production and $ m deploy-to-production --help will work Aditionally we can generate html out of the, now `makedown.md`, right in the tool: $ makedown --html makedown.html or $ m --pdf makedown.pdf
- efilife 2y agoRemember to change it in the readme as well
- timz 2y agoUpdated, makedown it is
- mbreese 2y agoI appreciate the quickness in renaming a project (x.md wasn’t great), but you’re missing the main point that Make provides - building a project based upon changing input files (DAGs and all of that). Make files are great in that they are flexible and allow this type of usage (especially with .PHONY), But without the “building” component to it, I found the name makedown confusing. Maybe that’s just me. But I like the project overall. I’m still trying to get my head around the syntax, but it looks nice. I’m also not sure I’ll switch from keeping scripts like this in my $HOME/.local/bin directory, but I can see how this is an appealing way to work.