diff options
-rw-r--r-- | lib/mixlib/cli.rb | 4 | ||||
-rw-r--r-- | spec/mixlib/cli_spec.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/mixlib/cli.rb b/lib/mixlib/cli.rb index bdaabdb..aa0b70b 100644 --- a/lib/mixlib/cli.rb +++ b/lib/mixlib/cli.rb @@ -128,6 +128,9 @@ module Mixlib # hash. attr_accessor :default_config + # Any arguments which were not parsed and placed in "config"--the leftovers. + attr_accessor :cli_arguments + # Banner for the option parser. If the option parser is printed, e.g., by # `puts opt_parser`, this string will be used as the first line. attr_accessor :banner @@ -235,6 +238,7 @@ module Mixlib end end + @cli_arguments = argv argv end diff --git a/spec/mixlib/cli_spec.rb b/spec/mixlib/cli_spec.rb index 39740b4..685af4e 100644 --- a/spec/mixlib/cli_spec.rb +++ b/spec/mixlib/cli_spec.rb @@ -206,10 +206,11 @@ describe Mixlib::CLI do ARGV.replace argv_old end - it "should return any un-parsed elements" do + it "should preserve and return any un-parsed elements" do TestCLI.option(:party, :short => "-p LOCATION") @cli = TestCLI.new - @cli.parse_options([ '-p', 'opscode', 'hard' ]).should == ['hard'] + @cli.parse_options([ 'easy', '-p', 'opscode', 'hard' ]).should == ['easy', 'hard'] + @cli.cli_arguments.should == ['easy', 'hard'] end end end |