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
More information available in the 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.