((((sandro.net))))

domingo, 13 de outubro de 2024

Show HN: A Markdown based alternative to package.json scripts and Makefiles https://ift.tt/pjvAQ9P

Show HN: A Markdown based alternative to package.json scripts and Makefiles `x.md` allows you to organise your cli scripts in one or several markdown files, by mix and matching different scripting languages for various commands, such as zsh/bash/sh, python or javascript. Handy for replacing one-line-based `package.json` scripts or `Makefile`s. One can also write documentation and explanations to various commands in same `x.md` markdown file. ZSH autocompletions are also working, suggesting you the most relevant available commands from your `x.md` files. Most editors highlight correctly most languages in the markdown code blocks, even when you use several scripting languages. Provided the following example (x.md file in the root of your project), one can run in a terminal: $ x weather-tomorrow or # x generate-password --- An example of x.md file --- # 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 x.md --- The syntax is simple, each command is a level 1 header followed by optional documentation in markdown notation, and followed by annotated (which interpreter to use) code block. One can type `--help` after `x my-command` to print out the help associated with that command. It is possible to have multiple files with scripts, just put them in the `x` folder with `.md` extension. Would be very grateful for any suggestions or other feedback. Thank you. https://ift.tt/jOfCtDS October 13, 2024 at 02:15AM

Nenhum comentário:

DJ Sandro

http://sandroxbox.listen2myradio.com