Getting Started
Welcome to Claptrap! This quick guide will help you install the tool and parse command line arguments in your shell scripts with ease.
Installation
Section titled “Installation”cargo install claptrap --locked
Basic Usage
Section titled “Basic Usage”Create a spec.toml
describing your arguments:
name = "myapp"version = "0.1.0"
[args]mode = { short = "m", long = "mode" }protocol = { short = "p", long = "protocol" }
Use Claptrap in your script:
#!/usr/bin/env bash
set -euo pipefail
eval "$(claptrap --spec spec.toml -- "$@")"
echo "mode: $claptrap_mode"echo "protocol: $claptrap_protocol"
Run your script:
$ ./myapp.sh -m normal --protocol httpmode: normalprotocol: http
That’s it! You’re now ready to clap 👏 and trap 🪤 your arguments!