Crates.io | spongecrab |
lib.rs | spongecrab |
version | |
source | src |
created_at | 2024-04-27 21:45:41.61653+00 |
updated_at | 2025-04-19 09:10:06.534788+00 |
description | Bringing powerful argument parsing to bash scripts |
homepage | |
repository | https://github.com/ArielHorwitz/spongecrab |
max_upload_size | |
id | 1222875 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Spongecrab - bringing powerful argument parsing to bash scripts
See '--example' and '--generate' for reference.
Usage: spongecrab [OPTIONS] [-- <INPUT>...]
Arguments:
[INPUT]... Raw text to parse
Options:
--name <NAME> Application name [default: myscript]
--about <ABOUT> Application about text
-p, --positional <POSITIONAL> Add a (required) positional argument
-o, --optional <OPTIONAL> Add an optional positional argument
-O, --option <OPTION> Add an optional argument
-f, --flag <FLAG> Add a flag argument
-c, --collect <COLLECT> Collect remaining positional arguments
-C, --collect+ <COLLECT> Collect (required) remaining positional arguments
-e, --extra <EXTRA> Collect extra optional arguments after '--'
-P, --prefix <PREFIX> Prefix for parsed variable names
-G, --generate Generate script boilerplate (see also '--example')
--example Generate example script
-h, --help Print help
-V, --version Print version
Generated code (using --generate
):
# Command line interface (based on `spongecrab --generate`)
APP_NAME=$(basename "${0%.*}")
ABOUT="program description"
# Argument syntax: "<arg_name>;<help_text>;<default_value>;<short_name>"
# -o, -c, -C are mutually exclusive
CLI=(
-p "arg1;Positional argument"
-o "arg2;Optional positional argument;<default value>"
-O "option;Optional argument;;o"
-f "flag;Optional flag argument;;f"
# -c "collect_any;Optional remaining positional arguments"
# -C "collect_some;Required remaining positional arguments"
-e "extra;Optional extra arguments after '--'"
)
CLI=$(spongecrab --name "$APP_NAME" --about "$ABOUT" "${CLI[@]}" -- "$@") || exit 1
eval "$CLI" || exit 1
See the example script.