diff --git a/bin/imag b/bin/imag new file mode 100755 index 00000000..fc8bd5ce --- /dev/null +++ b/bin/imag @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +version() { + echo "0.1.0" +} + +help() { + local cmds="$(commands)" + + cat < + + imag - the personal information management suite for the commandline + + imag is a PIM suite for the commandline. It consists of several commands, + called "modules". Each module implements one PIM aspect and all of these + modules can be used independently. + + Available commands: + $(for cmd in $cmds; do + echo -e "\t$(echo $cmd | sed -r 's,(.*)/imag-(.*),\2,')"; + done) + + Call a command with "imag " + Each command can be called with "--help" to get the respective helptext. + + Please visit https://github.com/matthiasbeyer/imag to view the source code, + follow the development of imag or maybe even contribute to imag. + + imag is free software. It is released under the terms of LGPLv2.1 + + (c) 2016 Matthias Beyer and contributors +EOS +} + +commands() { + [[ ! -z "$IMAG_IS_THE_SHIT" ]] && \ + find $IMAG_IS_THE_SHIT -type f -iname "imag-*" -print 2>/dev/null + find ${PATH//:/ } -maxdepth 1 -type f -iname "imag-*" -print 2>/dev/null +} + +main() { + case $1 in + --version) + version + exit 0 + ;; + + --help | -h) + help + exit 0 + ;; + + *) + local cmd=$1; shift + local executable=$(commands | grep $cmd | head -n 1) + exec $executable $* + ;; + + esac +} + +main $*