A simple shell wrapper that handles argument parsing
Rust 90.3%
Other 9.7%
1 1 0

Clone this repository

https://tangled.org/fly.nonsense.now/argsh
git@tangled.org:fly.nonsense.now/argsh

For self-hosted knots, clone URLs may differ based on your setup.

README.md

argsh#

This is a simple shell wrapper for scripts that handles argument parsing, because argument parsing in bash is a pain in the ass.

Usage#

Put argsh in the shebang, instead of your shell as such:

#!/bin/env argsh <arguments>

And you define the arguments as a semicolon separated list of arguments.

The only valid characters for an argument are a-z and -.

A plain argument such as arg is a required argument, which will be passed to the script as a positional argument.

An argument starting with $ such as $arg is an optional argument, which will be passed to the script as an environment variable like $ARGSH_ARG, where all - get converted to _.

Any additional positional arguments passed to the script get appended after the required arguments.

Optionally, you can set the shell to use as such bash|name;count, defaults to sh if ommited.

Limitations#

For the short version of arguments to work properly, all arguments must start with different characters.

All arguments must have a matching value, as such, flags aren't possible using argsh.

Limit of 256 arguments (if you have more than that please use an actual programming language).

Testing#

Run the test script as such and mess around with the arguments

./test --required indeed --also-required nice --optional woah --second-optional crazy am additional