Permalink
Browse files

added exit codes

  • Loading branch information...
1 parent bcc0f41 commit b2d868574b2f9e0bfd01eec151e88c8625c9f623 @PJK committed Dec 22, 2011
Showing with 7 additions and 3 deletions.
  1. +3 −3 bin/sparkdraw
  2. +4 −0 test/test_spark.rb
View
@@ -23,13 +23,13 @@ EXAMPLES:
▁▁▁▁▂▄█
HELP
-def show_help
+def show_help(status = 1)
puts Help
- exit
+ exit(status)
end
if ARGV.length > 0 then
- show_help if ['-h', '--help'].include? ARGV[0]
+ show_help(0) if ['-h', '--help'].include? ARGV[0]
# Parameters, accept both spaces and commas as separators
if ARGV.length == 1 then
show_help unless ARGV[0][/^(\d+[,])*\d+$/]
View
@@ -13,4 +13,8 @@ def test_it_accepts_stdin_input
assert_equal '▁▁▁▁▂▄█', `echo 2 4 8 16 32 64 128 | ./bin/sparkdraw`.strip
end
+ def test_it_fails
+ assert_equal false, system("./bin/sparkdraw dadadasd")
+ end
+
end

0 comments on commit b2d8685

Please sign in to comment.