#!/bin/sh
|
|
|
|
print_help() {
|
|
echo "$0 - pieces and operate on things"
|
|
echo
|
|
echo "Usage: pieces [command] [args]"
|
|
echo " pieces add [address] - Add a thing's address to the pieces list"
|
|
echo " pieces clear - Clear pieces list"
|
|
echo " pieces link - Link two addresses"
|
|
echo " pieces ls - List current piecess"
|
|
echo " pieces ls-print0 - List current piecess, separated by NUL chars"
|
|
echo " pieces remove - Remove a given URN from the pieces list"
|
|
echo " pieces -h - Print this help message"
|
|
echo
|
|
echo "You must specify a command."
|
|
exit 1
|
|
}
|
|
|
|
if [ $# -lt 1 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
|
print_help
|
|
fi
|
|
|
|
subprog="pieces-$1"
|
|
|
|
# Make sure that the command we've been given exists:
|
|
command -v "$subprog" >/dev/null 2>&1 || {
|
|
echo "pieces: '$1' is not a pieces command. See 'pieces -h'."
|
|
exit 1
|
|
}
|
|
|
|
shift
|
|
exec "$subprog" "$@"
|