diff --git a/lib/pry/cli.rb b/lib/pry/cli.rb index 781c2dbe..8e31788e 100644 --- a/lib/pry/cli.rb +++ b/lib/pry/cli.rb @@ -55,7 +55,7 @@ class Pry self.option_processors = nil end - def parse_options(args=ARGV.dup) + def parse_options(args=ARGV) unless options raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index cb30eb5e..0ce1019e 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -9,6 +9,16 @@ describe Pry::Hooks do it 'should raise if no options defined' do lambda { Pry::CLI.parse_options(["--nothing"]) }.should.raise Pry::CLI::NoOptionsError end + + it "should remove args from ARGV by default" do + ARGV << '-v' + Pry::CLI.add_options do + on :v, "Display the Pry version" do + # irrelevant + end + end.parse_options + ARGV.include?('-v').should == false + end end describe "adding options" do