Skip to content

fujiapple852/claptrap

Repository files navigation

ci Documentation Crate

Claptrap 👏🪤

Bring the power of clap command line parsing to shell scripts.

Examples

myapp.sh:

#!/usr/bin/env bash

set -euo pipefail

eval "$(claptrap --spec myapp.toml -- "$@")"

echo "mode: $claptrap_mode"
echo "protocol: $claptrap_protocol"

myapp.toml:

name = "myapp"
version = "0.1.0"

[args]
mode = { short = "m", long = "mode" }
protocol = { short = "p", long = "protocol" }

Show usage (also -h or --help):

$ ./myapp.sh
Usage: myapp [OPTIONS]

Options:
  -m, --mode <mode>
  -p, --protocol <protocol>
  -h, --help                 Print help
  -V, --version              Print version

Show version:

$ ./myapp.sh -V
myapp 0.1.0

Parse arguments:

$ ./myapp.sh -m normal --protocol http
mode: normal
protocol: http

Error handling:

$ ./myapp.sh -m normal --protocl http
error: unexpected argument '--protocl' found

  tip: a similar argument exists: '--protocol'

Usage: myapp --mode <mode> --protocol <protocol>

For more information, try '--help'.

Docker

To run Claptrap from a Docker container, you can use the following command. Make sure to mount the directory where the application specification file is located in the container.

docker run -it -v ${PWD}:/spec fujiapple/claptrap --spec /spec/myapp.toml

Installation

Cargo

Crates.io

cargo install claptrap --locked

Status

Incomplete WIP, unpublished, experimental.

Alternatives

License

Claptrap is distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.

Copyright 2025