Improved CLI help, updated URLs in read-me

This commit is contained in:
Michael Klement 2014-11-06 22:21:05 -05:00
parent 2ab070c353
commit fae24e926a
3 changed files with 22 additions and 20 deletions

View File

@ -28,6 +28,5 @@
{"name": "Tom Mortimer-Jones", "email": "tom@morty.co.uk"}
{"name": "Michael Klement", "email": "mklement0@gmail.com"}
],
"license": "BSD",
"readmeFilename": "readme.md"
"license": "BSD"
}

View File

@ -12,14 +12,14 @@ other Unix platforms.
Urchin's tests are written in Urchin, so you can run them to see what Urchin
is like. Clone the repository
git clone git://github.com/scraperwiki/urchin.git
git clone git://github.com/tlevine/urchin.git
Run the tests
cd urchin
./urchin tests
The above command will run the tests in your systems default
The above command will run the tests in your system's default
shell, /bin/sh (on recent Ubuntu this is dash, but it could be
ksh or bash on other systems); to test urchin's cross-shell compatibility,
run this:
@ -31,7 +31,7 @@ run this:
Download Urchin like so (as root) (or use npm, below):
cd /usr/local/bin
wget https://raw.github.com/scraperwiki/urchin/master/urchin
wget https://raw.github.com/tlevine/urchin/master/urchin
chmod +x urchin
Can be installed with npm too:
@ -154,4 +154,4 @@ It might make sense if you do this.
## Alternatives to Urchin
Alternatives to Urchin are discussed in
[this blog post](https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/).
[this blog post](https://blog.tlevine.com/2012/12/how-to-test-shell-scripts/).

31
urchin
View File

@ -95,19 +95,22 @@ has_sh_or_no_shebang_line() {
USAGE="usage: $0 [<options>] <test directory>"
urchin_help() {
echo
echo "$USAGE"
echo
echo '-s <shell> Invoke test scripts that either have no shebang line or'
echo ' shebang line "#!/bin/sh" with the specified shell.'
echo '-f Force running even if the test directory'\''s name does not'
echo ' contain the word "test".'
echo '-x Run "$TEST_SHELL", falling back on /bin/sh. This might be'
echo ' useful in the shebang line (experimental).'
echo '-h This help.'
echo
echo 'Go to https://github.com/tlevine/urchin for documentation on writing tests.'
echo
cat <<EOF
$USAGE
-s <shell> Invoke test scripts that either have no shebang line at all or
have shebang line "#!/bin/sh" with the specified shell.
-f Force running even if the test directory's name does not
contain the word "test".
-x [Experimental; not meant for direct invocation, but for use in
the shebang line of test scripts]
Run with "\$TEST_SHELL", falling back on /bin/sh.
-h This help.
Go to https://github.com/tlevine/urchin for documentation on writing tests.
EOF
}
plural () {
@ -175,7 +178,7 @@ do
shell_for_sh_tests=$1
which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; }
;;
-x) # `urchin -sh` is equivalent to "$TEST_SHELL"
-x) # `urchin -x <test-script>` is equivalent to `"$TEST_SHELL" <test-script>`
shift
urchinsh=${TEST_SHELL:-/bin/sh}
"$urchinsh" "$@"