shpec/shpec — pull request #29 by twe4ked (2013-03-03 05:12:38+00:00)
Title: Add --version command line option

I went with a case statement because `getopt` on BSD only supports single dash (short) options. I suggest moving the main runner code into a method that is called from the case statement similar to how [we have done it in fresh](https://github.com/freshshell/fresh/blob/4fe4036943ac30b6e5ecd6b41ed47240af668a53/bin/fresh#L593-L628) that way as more options get added the case statement will be easy to read. Let me know if you want anything changed.

Diff without the whitespace noise:

``` diff
# $ git show -w bin/shpec diff --git a/bin/shpec b/bin/shpec
index be0dd82..6179a2d 100755
--- a/bin/shpec
+++ b/bin/shpec
@@ -98,6 +98,14 @@ print_result() {
shpec_root="$(find . -name 'shpec' -type d | grep -v '.git')"
shpec_root="${shpec_root:-.}" # default to current directory

+case "$1" in
+
+ -v|--version )
+
+ cat "$shpec_root/../VERSION";;
+
+ * )
+
matcher_files="$(find "$shpec_root/matchers" -name '*.sh' 2>/dev/null)"

for matcher_file in $matcher_files; do
@@ -114,3 +122,5 @@ done
echo -e "${color}${examples} examples, ${failures} failures${norm}"

[ $failures -eq 0 ]
+
+esac
```

Closes #19.