Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Fix bin/kpeg when there are no arguments passed in #27

wants to merge 1 commit into from

1 participant


Was just playing around with a simple parser and noticed the following happens when you don't pass any arguments to kpeg:

sjothen@air% kpeg                                                    
/Library/Ruby/Gems/1.8/gems/kpeg-0.10.0/bin/kpeg:49:in `exists?': can't convert nil into String (TypeError)
    from /Library/Ruby/Gems/1.8/gems/kpeg-0.10.0/bin/kpeg:49
    from /usr/bin/kpeg:19:in `load'
    from /usr/bin/kpeg:19

This PR just adds a check after option parsing to print out the help information if no arguments are passed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 22, 2013
  1. @sjothen
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 2 deletions.
  1. +9 −2 bin/kpeg
11 bin/kpeg
@@ -8,7 +8,7 @@ require 'kpeg/grammar_renderer'
require 'optparse'
options = {} do |o|
+optparser = do |o|
o.banner = "Usage: kpeg [options]"
o.on("-t", "--test", "Syntax check the file only") do |v|
@@ -42,7 +42,14 @@ do |o|
o.on("-d", "--debug", "Debug parsing the file") do |v|
options[:debug] = v
+if ARGV.empty?
+ puts
+ exit 1
file = ARGV.shift
Something went wrong with that request. Please try again.