Transform your shell scripts into a powerful command-line interface with sub. This innovative tool organizes scripts, provides help documentation, validates and parses arguments, and supports nested commands, making script management effortless. Perfect for developers seeking efficiency in Linux and macOS environments.
sub: Shell Scripts with Superpowers 🦸♂️
Are you ready to elevate your shell scripting capabilities? Introducing sub, a powerful tool designed to streamline the organization of your scripts into a cohesive command-line interface. Whether you're working with multiple scripts or just looking to enhance your CLI experience, sub is here to empower you!
getopts by managing argument parsing seamlessly.Check out this engaging demonstration of sub in action! Watch it here.
Here's a simple usage example to get you started:
$ hat --help
You can invoke a subcommand like so:
$ hat user-script1
If you require help for a specific command, just use:
$ hat --help <commandname>
Documentation is key! To display help information seamlessly, sub extracts special comments from each script, allowing for clear and concise command explanations. An example command documentation might look like this:
#!/usr/bin/env bash
# Summary: Say hello
# Usage: {cmd} <name> [--spanish]
# Say hello to a user by name.
# With the --spanish flag, the greeting will be in Spanish.
Sub automatically validates command line arguments, improving user interaction and providing clear feedback when required arguments are missing. Furthermore, arguments are structured for easy access through associative arrays in bash, simplifying the scripting process:
declare -A args="($_HAT_ARGS)"
Support for nested command structures allows for organized script collections, while aliases can be created for easy access. Need to share code among scripts? Use the environment variable _HAT_ROOT to source shared libraries effortlessly.
Leverage caching to maintain temporary files across subcommands, effectively enhancing runtime efficiency.
With sub, you have all the essential tools to enhance your scripting capabilities and streamline your command-line interface! Dive into endless possibilities with sub and maximize the potential of your shell scripts today!
No comments yet.
Sign in to be the first to comment.