Bash is powerful but painful. Rad gives you Python-like scripting with CLI superpowers built-in. Write maintainable scripts with declarative argument parsing, built-in JSON processing, HTTP requests, and intuitive user prompts. Transform how CLI tools are built with ease and efficiency.
Rad is an innovative scripting language designed to provide the power of Bash with the simplicity and readability of Python. It addresses the challenges associated with traditional Bash scripts by offering built-in support for argument parsing, JSON processing, and HTTP requests, simplifying the scripting process for developers.
Key Features of Rad:
- CLI-first Design: Rad is inherently designed for command-line operations, ensuring that argument validation and help commands are seamlessly integrated into the language.
- Familiar Syntax: With syntax inspired by Python, Rad eliminates the complexity of Bash, making scripts easier to read and maintain.
- Declarative Argument Handling: Automatic help generation, type-checking, validation, and parsing for arguments is built into the language, reducing the amount of boilerplate code necessary.
- Simplified JSON Processing: Rad provides straightforward paths for extracting data from JSON, facilitating easy data manipulation and output formatting.
- Built-in HTTP Support: Effortlessly query APIs and handle responses with minimal code required.
- Interactive Prompts: Features like
pick()andinput()allow for simple user input handling and interactive menus, enhancing user experience. - Shell Command Execution: Enables execution of shell commands and capturing of their output within scripts.
Example Usage
Rad allows straightforward script writing that dramatically reduces the complexity typical of Bash. For instance, a script to fetch GitHub commits can be written as follows:
#!/usr/bin/env rad
args:
repo str # The repo to query. Format: user/project
limit int = 20 # Max commits to return
url = "https://api.github.com/repos/{repo}/commits?per_page={limit}"
Time = json[].commit.author.date
Author = json[].commit.author.name
SHA = json[].sha
rad url:
fields Time, Author, SHA
This Rad script fetches commit details without additional tools or complex commands, showcasing its efficiency and ease of use.
Comparison with Other Scripting Languages
Rad stacks up against Bash and Python in several key areas:
| Feature | Bash | Python | Rad |
|---|---|---|---|
| Syntax familiarity | Archaic, hard to remember | Familiar | Familiar (Python-like) |
| Argument parsing | Verbose, manual | argparse or libraries | Built-in; declarative |
| Type checking | None | Manual or library | Built-in |
| --help generation | Manual | Dependencies handle it | Built-in; auto from comments |
| Validation/constraints | Manual | Manual or library schemas | Built-in (range, enum, etc) |
| JSON processing | Pipe to jq | JSON module + manual handling | Built-in path syntax |
| HTTP requests | curl + pipes | Import requests | Built-in; first-class support |
Next Steps
Rad is currently in early development, with core features functioning effectively. It is continuously improved based on community feedback. Those interested in refining their scripting experience with fewer dependencies and more intuitive syntax will find value in trying Rad.
Documentation
For more information and a detailed "Getting Started" tutorial, please visit the official documentation.
No comments yet.
Sign in to be the first to comment.