Test commit
[cogito/jonas.git] / cg
blobbc3b8ccbd41cf27c15f4f0327d94f3571c72baf6
1 #!/usr/bin/env bash
3 # Wrapper for running Cogito commands.
4 # Copyright (c) Petr Baudis, 2005
6 # Takes a variable number of arguments where the first argument should
7 # either be a Cogito command or one of the supported options. If no
8 # arguments are specified an overview of all the Cogito commands will be
9 # shown.
11 # Enables all Cogito commands to be accessed as subcommands, for example
12 # is:
14 # cg help
15 # cg-help
17 # equivalent.
19 # OPTIONS
20 # -------
21 # --version:: Show the Cogito toolkit version
22 # Show the version of the Cogito toolkit. Equivalent to the output
23 # of `cg-version`.
25 USAGE="cg [--version | COMMAND [ARGS]...]"
27 cmd="$1"; shift
28 case "$cmd" in
29 -h|--help|"") cmd="help" ;;
30 --version) cmd="version" ;;
31 -*)
32 echo "cg: unknown option '$cmd' (try 'cg --help' or 'cg --version')" >&2
33 exit 1
34 esac
36 exe="cg-$cmd"
38 # Cut'n'pasted from cg-Xlib
39 save_IFS="$IFS"; IFS=:
40 for dir in $PATH; do
41 IFS="$save_IFS"
42 exefile="$dir/$exe"
43 [ -x "$exefile" ] && exec "$exefile" "$@"
44 done
45 IFS="$save_IFS"
47 echo "cg: unknown command '$cmd' (try 'cg help')" >&2
48 exit 1