PitchHut logo
Unleash the power of your scripts with an intuitive CLI.
Pitch

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.

Description

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!

Key Features

  • Dynamic CLI Creation: Effortlessly create a unified command-line interface from a directory and its subdirectories, allowing for quick access to all your scripts.
  • Comprehensive Help Documentation: Automatically displays usage and documentation for each script, ensuring users have all the information they need at their fingertips.
  • Argument Validation: Validates script arguments based on defined documentation, keeping your commands error-free.
  • Automatic Argument Parsing: Avoids the hassle of using getopts by managing argument parsing seamlessly.
  • Nested Subcommands: Supports hierarchical command structures through nested directories, allowing for organized and intuitive command hierarchies.
  • Alias Support: Easily create shortcuts for your commands by defining aliases, enhancing your workflow.
  • Cross-Platform Compatibility: Works effortlessly on both Linux and macOS systems, making it versatile for different environments.
  • Completions: Benefit from auto-completion of subcommands, enhancing productivity while using your CLI.

Demo

Check out this engaging demonstration of sub in action! Watch it here.

Usage Example

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>

Documenting Commands

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.

Validating and Parsing Arguments

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)"

Nesting and Aliasing

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.

Caching Mechanism

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!

0 comments

No comments yet.

Sign in to be the first to comment.