You are not logged in.

#1 2012-10-29 00:09:23

AaronBP
Member
Registered: 2012-08-06
Posts: 149
Website

docopts

Just put up a PKGBUILD for docopts. It's the CLI interface to docopt.

Here's a script to show how it's useful:

#!/bin/sh

usage="calc - Simplified bc wrapper

Usage:
    calc [options] <expression>
    calc -h | --help

Description:
    Tired of having to type some long line just to get the answer to
    get to important questions like '2 + 2'? Me, too!

Options:
    -s <number> --scale=<number>    Set decimal precision (default 2)
    -h --help                       Print this help message"

eval "$(docopts "$usage" "$version" "--" "$@")"

if [ ! $scale ]
then
	scale=2
fi

echo "scale=$scale;" "$expression" | bc

Is that not most amazing thing you've ever seen? Computers are glorious.

Offline

Board footer

Powered by FluxBB