Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --update and --version #7

Merged
merged 2 commits into from Jul 5, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 42 additions & 20 deletions spot.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

version="0.0.1"

# search directory defaults to current
dir=.

Expand All @@ -21,7 +23,7 @@ cyan=`echo -e '\033[96m'`
reset=`echo -e '\033[39m'`

# usage info
function usage {
usage() {
cat <<EOF

Usage: spot [options] [directory] [term ...]
Expand All @@ -32,32 +34,52 @@ function usage {
-i, --insensitive Force case insensitive search.
-C, --no-colors Force avoid colors.
-L, --no-linenums Hide line numbers.
-U, --update Update spot(1)
-V, --version Output version
-h, --help This message.

EOF
}

# update spot(1) via git clone
update() {
cd /tmp \
&& echo "... updating" \
&& git clone --depth 1 git://github.com/guille/spot.git \
&& cd spot \
&& make install \
&& echo "... updated to $(spot --version)"
exit
}

# parse options
while [[ "$1" =~ ^- ]]; do
case $1 in
-s | --sensitive )
sensitive=1
;;
-i | --insensitive )
sensitive=
;;
-C | --no-colors )
colors=
;;
-L | --no-linenums )
linenums=
;;
-h | --help )
usage
exit
;;
esac
shift
case $1 in
-V | --version )
echo $version
exit
;;
-s | --sensitive )
sensitive=1
;;
-i | --insensitive )
sensitive=
;;
-C | --no-colors )
colors=
;;
-L | --no-linenums )
linenums=
;;
-U | --update )
update
;;
-h | --help )
usage
exit
;;
esac
shift
done

# check for directory as first parameter
Expand Down