kook/bin/kotam

52 lines
974 B
Text
Raw Normal View History

2013-06-04 13:46:44 +00:00
#!/bin/sh
2013-06-04 14:08:18 +00:00
KOTAM_DATA_DIR=$(cd `dirname "$0"`; cd ../lib ; pwd )
KOTAM_CONFIG_DIR=$HOME/.config/kotam
2013-06-04 13:46:44 +00:00
2013-06-04 14:08:18 +00:00
. $KOTAM_DATA_DIR/base.sh
2013-06-04 13:46:44 +00:00
## Expected usage :
#
2013-06-04 14:08:18 +00:00
# kotam exec <name>
# kotam init <name>
2013-06-04 13:46:44 +00:00
#
2013-06-04 14:08:18 +00:00
mkdir -p $KOTAM_CONFIG_DIR
2013-06-04 13:46:44 +00:00
while [ $# -gt 0 ]; do
arg=${1:-}
opt=${2:-}
case $arg in
-l|--list) #list projects
echo "List of projects :"
2013-06-04 14:08:18 +00:00
ls $KOTAM_CONFIG_DIR/*.kotam 2> /dev/null
2013-06-04 13:46:44 +00:00
;;
-e) # edit project
shift
project="$opt"
if [ -z "$project" ]; then
echo "ERROR: project name missing" >&2
exit 1
2013-06-04 14:08:18 +00:00
elif [ ! -e "$KOTAM_CONFIG_DIR/$project.kotam" ]; then
2013-06-04 13:46:44 +00:00
echo "ERROR: unknown project $project" >&2
exit 1
fi
2013-06-04 14:08:18 +00:00
"$EDITOR" "$KOTAM_CONFIG_DIR/$project.kotam"
2013-06-04 13:46:44 +00:00
;;
-c) # create
;;
-d) # destroy
;;
*) #enter into project
project="$arg"
2013-06-04 14:08:18 +00:00
if [ ! -e "$KOTAM_CONFIG_DIR/$project.kotam" ]; then
2013-06-04 13:46:44 +00:00
echo "ERROR: unknown project $project" >&2
exit 1
fi
2013-06-04 14:08:18 +00:00
. "$KOTAM_CONFIG_DIR/$project.kotam"
2013-06-04 13:46:44 +00:00
;;
esac
shift
done