Hello community,
here is the log from the commit of package rubygem-mixlib-cli for openSUSE:Factory checked in at 2019-03-04 09:20:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-mixlib-cli (Old)
and /work/SRC/openSUSE:Factory/.rubygem-mixlib-cli.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-mixlib-cli"
Mon Mar 4 09:20:07 2019 rev:10 rq:679522 version:2.0.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-mixlib-cli/rubygem-mixlib-cli.changes 2016-07-12 23:52:34.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-mixlib-cli.new.28833/rubygem-mixlib-cli.changes 2019-03-04 09:20:10.068603221 +0100
@@ -1,0 +2,6 @@
+Mon Jan 14 13:46:16 UTC 2019 - Stephan Kulow
+
+- updated to version 2.0.1
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
mixlib-cli-1.7.0.gem
New:
----
mixlib-cli-2.0.1.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-mixlib-cli.spec ++++++
--- /var/tmp/diff_new_pack.TALLwz/_old 2019-03-04 09:20:10.804603088 +0100
+++ /var/tmp/diff_new_pack.TALLwz/_new 2019-03-04 09:20:10.808603088 +0100
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-mixlib-cli
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@@ -24,16 +24,16 @@
#
Name: rubygem-mixlib-cli
-Version: 1.7.0
+Version: 2.0.1
Release: 0
%define mod_name mixlib-cli
%define mod_full_name %{mod_name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
+BuildRequires: %{ruby >= 2.5}
BuildRequires: %{rubygem gem2rpm}
-BuildRequires: %{ruby}
BuildRequires: ruby-macros >= 5
-Url: https://www.chef.io
-Source: http://rubygems.org/gems/%{mod_full_name}.gem
+Url: https://www.github.com/mixlib-cli
+Source: https://rubygems.org/gems/%{mod_full_name}.gem
Source1: gem2rpm.yml
Summary: A simple mixin for CLI interfaces, including option parsing
License: Apache-2.0
@@ -48,7 +48,7 @@
%install
%gem_install \
- --doc-files="LICENSE README.md" \
+ --doc-files="LICENSE" \
-f
%gem_packages
++++++ mixlib-cli-1.7.0.gem -> mixlib-cli-2.0.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile
--- old/Gemfile 2016-07-06 15:58:04.000000000 +0200
+++ new/Gemfile 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-source "https://rubygems.org"
-
-gemspec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NOTICE new/NOTICE
--- old/NOTICE 2016-07-06 15:58:04.000000000 +0200
+++ new/NOTICE 2019-01-04 20:07:04.000000000 +0100
@@ -4,7 +4,7 @@
Developed at Chef (http://www.chef.io).
- * Copyright 2009-2016, Chef Software, Inc.
+ * Copyright 2009-2018, Chef Software, Inc.
Mixin::CLI incorporates code from Chef. The Chef notice file follows:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2016-07-06 15:58:04.000000000 +0200
+++ new/README.md 1970-01-01 01:00:00.000000000 +0100
@@ -1,109 +0,0 @@
-# Mixlib::CLI
-
-[![Build Status Master](https://travis-ci.org/chef/mixlib-cli.svg?branch=master)](https://travis-ci.org/chef/mixlib-cli) [![Gem Version](https://badge.fury.io/rb/mixlib-cli.svg)](https://badge.fury.io/rb/mixlib-cli)
-
-Mixlib::CLI provides a class-based command line option parsing object, like the one used in Chef, Ohai and Relish. To use in your project:
-
-```ruby
-require 'rubygems'
-require 'mixlib/cli'
-
-class MyCLI
- include Mixlib::CLI
-
- option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => 'config.rb',
- :description => "The configuration file to use"
-
- option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (debug, info, warn, error, fatal)",
- :required => true,
- :in => ['debug', 'info', 'warn', 'error', 'fatal'],
- :proc => Proc.new { |l| l.to_sym }
-
- option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
-
-end
-
-# ARGV = [ '-c', 'foo.rb', '-l', 'debug' ]
-cli = MyCLI.new
-cli.parse_options
-cli.config[:config_file] # 'foo.rb'
-cli.config[:log_level] # :debug
-```
-
-If you are using this in conjunction with Mixlib::Config, you can do something like this (building on the above definition):
-
-```ruby
-class MyConfig
- extend(Mixlib::Config)
-
- log_level :info
- config_file "default.rb"
-end
-
-class MyCLI
- def run(argv=ARGV)
- parse_options(argv)
- MyConfig.merge!(config)
- end
-end
-
-c = MyCLI.new
-# ARGV = [ '-l', 'debug' ]
-c.run
-MyConfig[:log_level] # :debug
-```
-
-Available arguments to 'option':
-
-- `:short`: The short option, just like from optparse. Example: "-l LEVEL"
-- `:long`: The long option, just like from optparse. Example: "--level LEVEL"
-- `:description`: The description for this item, just like from optparse.
-- `:default`: A default value for this option
-- `:required`: Prints a message informing the user of the missing requirement, and exits. Default is false.
-- `:on`: Set to :tail to appear at the end, or `:head`: to appear at the top.
-- `:boolean:`: If this option takes no arguments, set this to true.
-- `:show_options`: If you want the option list printed when this option is called, set this to true.
-- `:exit`: Exit your program with the exit code when this option is specified. Example: 0
-- `:proc`: If set, the configuration value will be set to the return value of this proc.
-- `:in`: An array containing the list of accepted values
-
-If you need access to the leftover options that aren't captured in the config, you can get at them through +cli_arguments+ (referring to the above definition of MyCLI).
-
-```ruby
-# ARGV = [ '-c', 'foo.rb', '-l', 'debug', 'file1', 'file2', 'file3' ]
-cli = MyCLI.new
-cli.parse_options
-cli.cli_arguments # [ 'file1', 'file2', 'file3' ]
-```
-
-## LICENSE:
-
-- Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
-- License:: Apache License, Version 2.0
-
-```text
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile
--- old/Rakefile 2016-07-06 15:58:04.000000000 +0200
+++ new/Rakefile 1970-01-01 01:00:00.000000000 +0100
@@ -1,33 +0,0 @@
-require "bundler"
-require "rubygems"
-require "rubygems/package_task"
-require "rdoc/task"
-require "rspec/core/rake_task"
-
-Bundler::GemHelper.install_tasks
-
-task :default => :spec
-
-desc "Run specs"
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.pattern = "spec/**/*_spec.rb"
-end
-
-gem_spec = eval(File.read("mixlib-cli.gemspec"))
-
-RDoc::Task.new do |rdoc|
- rdoc.rdoc_dir = "rdoc"
- rdoc.title = "mixlib-cli #{gem_spec.version}"
- rdoc.rdoc_files.include("README*")
- rdoc.rdoc_files.include("lib/**/*.rb")
-end
-
-begin
- require "chefstyle"
- require "rubocop/rake_task"
- RuboCop::RakeTask.new(:style) do |task|
- task.options += ["--display-cop-names", "--no-color"]
- end
-rescue LoadError
- puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking."
-end
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/cli/version.rb new/lib/mixlib/cli/version.rb
--- old/lib/mixlib/cli/version.rb 2016-07-06 15:58:04.000000000 +0200
+++ new/lib/mixlib/cli/version.rb 2019-01-04 20:07:04.000000000 +0100
@@ -1,5 +1,5 @@
module Mixlib
module CLI
- VERSION = "1.7.0"
+ VERSION = "2.0.1".freeze
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/cli.rb new/lib/mixlib/cli.rb
--- old/lib/mixlib/cli.rb 2016-07-06 15:58:04.000000000 +0200
+++ new/lib/mixlib/cli.rb 2019-01-04 20:07:04.000000000 +0100
@@ -1,6 +1,6 @@
#
-# Author:: Adam Jacob ()
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Adam Jacob ()
+# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,7 @@
module InheritMethods
def inherited(receiver)
- receiver.options = deep_dup(self.options)
+ receiver.options = deep_dup(options)
receiver.extend(Mixlib::CLI::InheritMethods)
end
@@ -210,7 +210,7 @@
config_opts[:exit] ||= nil
config_opts[:in] ||= nil
- if config_opts.has_key?(:default)
+ if config_opts.key?(:default)
defaults_container[config_key] = config_opts[:default]
end
end
@@ -231,7 +231,7 @@
# Deal with any required values
options.each do |opt_key, opt_value|
- if opt_value[:required] && !config.has_key?(opt_key)
+ if opt_value[:required] && !config.key?(opt_key)
reqarg = opt_value[:short] || opt_value[:long]
puts "You must supply #{reqarg}!"
puts @opt_parser
@@ -241,7 +241,7 @@
unless opt_value[:in].kind_of?(Array)
raise(ArgumentError, "Options config key :in must receive an Array")
end
- if !opt_value[:in].include?(config[opt_key])
+ if config[opt_key] && !opt_value[:in].include?(config[opt_key])
reqarg = opt_value[:short] || opt_value[:long]
puts "#{reqarg}: #{config[opt_key]} is not included in the list ['#{opt_value[:in].join("', '")}'] "
puts @opt_parser
@@ -308,12 +308,13 @@
def build_option_arguments(opt_setting)
arguments = Array.new
- arguments << opt_setting[:short] if opt_setting.has_key?(:short)
- arguments << opt_setting[:long] if opt_setting.has_key?(:long)
- if opt_setting.has_key?(:description)
- description = opt_setting[:description]
+ arguments << opt_setting[:short] if opt_setting.key?(:short)
+ arguments << opt_setting[:long] if opt_setting.key?(:long)
+ if opt_setting.key?(:description)
+ description = opt_setting[:description].dup
description << " (required)" if opt_setting[:required]
description << " (included in ['#{opt_setting[:in].join("', '")}'])" if opt_setting[:in]
+ opt_setting[:description] = description
arguments << description
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2016-07-06 15:58:04.000000000 +0200
+++ new/metadata 2019-01-04 20:07:04.000000000 +0100
@@ -1,91 +1,26 @@
--- !ruby/object:Gem::Specification
name: mixlib-cli
version: !ruby/object:Gem::Version
- version: 1.7.0
+ version: 2.0.1
platform: ruby
authors:
- Chef Software, Inc.
autorequire:
bindir: bin
cert_chain: []
-date: 2016-07-06 00:00:00.000000000 Z
-dependencies:
-- !ruby/object:Gem::Dependency
- name: rake
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "<"
- - !ruby/object:Gem::Version
- version: '11.0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "<"
- - !ruby/object:Gem::Version
- version: '11.0'
-- !ruby/object:Gem::Dependency
- name: rspec
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '2.14'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '2.14'
-- !ruby/object:Gem::Dependency
- name: rdoc
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-- !ruby/object:Gem::Dependency
- name: chefstyle
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '0.3'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '0.3'
+date: 2019-01-04 00:00:00.000000000 Z
+dependencies: []
description: A simple mixin for CLI interfaces, including option parsing
email: info@chef.io
executables: []
extensions: []
-extra_rdoc_files:
-- README.md
-- LICENSE
-- NOTICE
+extra_rdoc_files: []
files:
-- Gemfile
- LICENSE
- NOTICE
-- README.md
-- Rakefile
- lib/mixlib/cli.rb
- lib/mixlib/cli/version.rb
-- mixlib-cli.gemspec
-- spec/mixlib/cli_spec.rb
-- spec/spec_helper.rb
-homepage: https://www.chef.io
+homepage: https://www.github.com/mixlib-cli
licenses:
- Apache-2.0
metadata: {}
@@ -97,7 +32,7 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '0'
+ version: '2.5'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
@@ -105,7 +40,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.4.5.1
+rubygems_version: 2.7.6
signing_key:
specification_version: 4
summary: A simple mixin for CLI interfaces, including option parsing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mixlib-cli.gemspec new/mixlib-cli.gemspec
--- old/mixlib-cli.gemspec 2016-07-06 15:58:04.000000000 +0200
+++ new/mixlib-cli.gemspec 1970-01-01 01:00:00.000000000 +0100
@@ -1,27 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + "/lib")
-require "mixlib/cli/version"
-
-Gem::Specification.new do |s|
- s.name = "mixlib-cli"
- s.version = Mixlib::CLI::VERSION
- s.platform = Gem::Platform::RUBY
- s.has_rdoc = true
- s.extra_rdoc_files = ["README.md", "LICENSE", "NOTICE"]
- s.summary = "A simple mixin for CLI interfaces, including option parsing"
- s.description = s.summary
- s.author = "Chef Software, Inc."
- s.email = "info@chef.io"
- s.homepage = "https://www.chef.io"
- s.license = "Apache-2.0"
-
- # Uncomment this to add a dependency
- #s.add_dependency "mixlib-log"
- s.add_development_dependency "rake", "< 11.0"
- s.add_development_dependency "rspec", "~> 2.14"
- s.add_development_dependency "rdoc"
- s.add_development_dependency "chefstyle", "~> 0.3"
-
- s.require_path = "lib"
- s.files = %w{LICENSE README.md Gemfile Rakefile NOTICE} + Dir.glob("*.gemspec") +
- Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mixlib/cli_spec.rb new/spec/mixlib/cli_spec.rb
--- old/spec/mixlib/cli_spec.rb 2016-07-06 15:58:04.000000000 +0200
+++ new/spec/mixlib/cli_spec.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,345 +0,0 @@
-#
-# Author:: Adam Jacob ()
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
-
-describe Mixlib::CLI do
- after(:each) do
- TestCLI.options = {}
- TestCLI.banner("Usage: #{$0} (options)")
- end
-
- describe "class method" do
- describe "option" do
- it "should allow you to set a config option with a hash" do
- TestCLI.option(:config_file, :short => "-c CONFIG").should == { :short => "-c CONFIG" }
- end
- end
-
- describe "options" do
- it "should return the current options hash" do
- TestCLI.option(:config_file, :short => "-c CONFIG")
- TestCLI.options.should == { :config_file => { :short => "-c CONFIG" } }
- end
- end
-
- describe "options=" do
- it "should allow you to set the full options with a single hash" do
- TestCLI.options = { :config_file => { :short => "-c CONFIG" } }
- TestCLI.options.should == { :config_file => { :short => "-c CONFIG" } }
- end
- end
-
- describe "banner" do
- it "should have a default value" do
- TestCLI.banner.should =~ /^Usage: (.+) \(options\)$/
- end
-
- it "should allow you to set the banner" do
- TestCLI.banner("Usage: foo")
- TestCLI.banner.should == "Usage: foo"
- end
- end
- end
-
- context "when configured with default single-config-hash behavior" do
-
- before(:each) do
- @cli = TestCLI.new
- end
-
- describe "initialize" do
- it "should set the banner to the class defined banner" do
- @cli.banner.should == TestCLI.banner
- end
-
- it "should set the options to the class defined options, plus defaults" do
- TestCLI.option(:config_file, :short => "-l LOG")
- cli = TestCLI.new
- cli.options.should == {
- :config_file => {
- :short => "-l LOG",
- :on => :on,
- :boolean => false,
- :required => false,
- :proc => nil,
- :show_options => false,
- :exit => nil,
- :in => nil,
- },
- }
- end
-
- it "should set the default config value for any options that include it" do
- TestCLI.option(:config_file, :short => "-l LOG", :default => :debug)
- @cli = TestCLI.new
- @cli.config[:config_file].should == :debug
- end
- end
-
- describe "opt_parser" do
-
- it "should set the banner in opt_parse" do
- @cli.opt_parser.banner.should == @cli.banner
- end
-
- it "should present the arguments in the banner" do
- TestCLI.option(:config_file, :short => "-l LOG")
- @cli = TestCLI.new
- @cli.opt_parser.to_s.should =~ /-l LOG/
- end
-
- it "should honor :on => :tail options in the banner" do
- TestCLI.option(:config_file, :short => "-l LOG")
- TestCLI.option(:help, :short => "-h", :boolean => true, :on => :tail)
- @cli = TestCLI.new
- @cli.opt_parser.to_s.split("\n").last.should =~ /-h/
- end
-
- it "should honor :on => :head options in the banner" do
- TestCLI.option(:config_file, :short => "-l LOG")
- TestCLI.option(:help, :short => "-h", :boolean => true, :on => :head)
- @cli = TestCLI.new
- @cli.opt_parser.to_s.split("\n")[1].should =~ /-h/
- end
-
- it "should present the arguments in alphabetical order in the banner" do
- TestCLI.option(:alpha, :short => "-a ALPHA")
- TestCLI.option(:beta, :short => "-b BETA")
- TestCLI.option(:zeta, :short => "-z ZETA")
- @cli = TestCLI.new
- output_lines = @cli.opt_parser.to_s.split("\n")
- output_lines[1].should =~ /-a ALPHA/
- output_lines[2].should =~ /-b BETA/
- output_lines[3].should =~ /-z ZETA/
- end
-
- end
-
- describe "parse_options" do
- it "should set the corresponding config value for non-boolean arguments" do
- TestCLI.option(:config_file, :short => "-c CONFIG")
- @cli = TestCLI.new
- @cli.parse_options([ "-c", "foo.rb" ])
- @cli.config[:config_file].should == "foo.rb"
- end
-
- it "should set the corresponding config value according to a supplied proc" do
- TestCLI.option(:number,
- :short => "-n NUMBER",
- :proc => Proc.new { |config| config.to_i + 2 }
- )
- @cli = TestCLI.new
- @cli.parse_options([ "-n", "2" ])
- @cli.config[:number].should == 4
- end
-
- it "should pass the existing value to two-argument procs" do
- TestCLI.option(:number,
- :short => "-n NUMBER",
- :proc => Proc.new { |value, existing| existing ||= []; existing << value; existing }
- )
- @cli = TestCLI.new
- @cli.parse_options([ "-n", "2", "-n", "3" ])
- @cli.config[:number].should == %w{2 3}
- end
-
- it "should set the corresponding config value to true for boolean arguments" do
- TestCLI.option(:i_am_boolean, :short => "-i", :boolean => true)
- @cli = TestCLI.new
- @cli.parse_options([ "-i" ])
- @cli.config[:i_am_boolean].should == true
- end
-
- it "should set the corresponding config value to false when a boolean is prefixed with --no" do
- TestCLI.option(:i_am_boolean, :long => "--[no-]bool", :boolean => true)
- @cli = TestCLI.new
- @cli.parse_options([ "--no-bool" ])
- @cli.config[:i_am_boolean].should == false
- end
-
- it "should exit if a config option has :exit set" do
- TestCLI.option(:i_am_exit, :short => "-x", :boolean => true, :exit => 0)
- @cli = TestCLI.new
- lambda { @cli.parse_options(["-x"]) }.should raise_error(SystemExit)
- end
-
- it "should exit if a required option is missing" do
- TestCLI.option(:require_me, :short => "-r", :boolean => true, :required => true)
- @cli = TestCLI.new
- lambda { @cli.parse_options([]) }.should raise_error(SystemExit)
- end
-
- it "should exit if option is not included in the list" do
- TestCLI.option(:inclusion, :short => "-i val", :in => %w{one two})
- @cli = TestCLI.new
- lambda { @cli.parse_options(["-i", "three"]) }.should raise_error(SystemExit)
- end
-
- it "should raise ArgumentError if options key :in is not an array" do
- TestCLI.option(:inclusion, :short => "-i val", :in => "foo")
- @cli = TestCLI.new
- lambda { @cli.parse_options(["-i", "three"]) }.should raise_error(ArgumentError)
- end
-
- it "should not exit if option is included in the list" do
- TestCLI.option(:inclusion, :short => "-i val", :in => %w{one two})
- @cli = TestCLI.new
- @cli.parse_options(["-i", "one"])
- @cli.config[:inclusion].should == "one"
- end
-
- it "should change description if :in key is specified" do
- TestCLI.option(:inclusion, :short => "-i val", :in => %w{one two}, :description => "desc")
- @cli = TestCLI.new
- @cli.parse_options(["-i", "one"])
- @cli.options[:inclusion][:description].should == "desc (included in ['one', 'two'])"
- end
-
- it "should not exit if a required option is specified" do
- TestCLI.option(:require_me, :short => "-r", :boolean => true, :required => true)
- @cli = TestCLI.new
- @cli.parse_options(["-r"])
- @cli.config[:require_me].should == true
- end
-
- it "should not exit if a required boolean option is specified and false" do
- TestCLI.option(:require_me, :long => "--[no-]req", :boolean => true, :required => true)
- @cli = TestCLI.new
- @cli.parse_options(["--no-req"])
- @cli.config[:require_me].should == false
- end
-
- it "should not exit if a required option is specified and empty" do
- TestCLI.option(:require_me, :short => "-r VALUE", :required => true)
- @cli = TestCLI.new
- @cli.parse_options(["-r", ""])
- @cli.config[:require_me].should == ""
- end
-
- it "should preserve all of the commandline arguments, ARGV" do
- TestCLI.option(:config_file, :short => "-c CONFIG")
- @cli = TestCLI.new
- argv_old = ARGV.dup
- ARGV.replace ["-c", "foo.rb"]
- @cli.parse_options()
- ARGV.should == ["-c", "foo.rb"]
- ARGV.replace argv_old
- end
-
- it "should preserve and return any un-parsed elements" do
- TestCLI.option(:party, :short => "-p LOCATION")
- @cli = TestCLI.new
- @cli.parse_options([ "easy", "-p", "opscode", "hard" ]).should == %w{easy hard}
- @cli.cli_arguments.should == %w{easy hard}
- end
- end
- end
-
- context "when configured to separate default options" do
- before do
- TestCLI.use_separate_default_options true
- TestCLI.option(:defaulter, :short => "-D SOMETHING", :default => "this is the default")
- @cli = TestCLI.new
- end
-
- it "sets default values on the `default` hash" do
- @cli.parse_options([])
- @cli.default_config[:defaulter].should == "this is the default"
- @cli.config[:defaulter].should be_nil
- end
-
- it "sets parsed values on the `config` hash" do
- @cli.parse_options(%w{-D not-default})
- @cli.default_config[:defaulter].should == "this is the default"
- @cli.config[:defaulter].should == "not-default"
- end
-
- end
-
- context "when subclassed" do
- before do
- TestCLI.options = { :arg1 => { :boolean => true } }
- end
-
- it "should retain previously defined options from parent" do
- class T1 < TestCLI
- option :arg2, :boolean => true
- end
- T1.options[:arg1].should be_a(Hash)
- T1.options[:arg2].should be_a(Hash)
- TestCLI.options[:arg2].should be_nil
- end
-
- it "should not be able to modify parent classes options" do
- class T2 < TestCLI
- option :arg2, :boolean => true
- end
- T2.options[:arg1][:boolean] = false
- T2.options[:arg1][:boolean].should be_false
- TestCLI.options[:arg1][:boolean].should be_true
- end
-
- it "should pass its options onto child" do
- class T3 < TestCLI
- option :arg2, :boolean => true
- end
- class T4 < T3
- option :arg3, :boolean => true
- end
- 3.times do |i|
- T4.options["arg#{i + 1}".to_sym].should be_a(Hash)
- end
- end
-
- it "should also work with an option that's an array" do
- class T5 < TestCLI
- option :arg2, :default => []
- end
-
- class T6 < T5
- end
-
- T6.options[:arg2].should be_a(Hash)
- end
-
- end
-
-end
-
-# option :config_file,
-# :short => "-c CONFIG",
-# :long => "--config CONFIG",
-# :default => 'config.rb',
-# :description => "The configuration file to use"
-#
-# option :log_level,
-# :short => "-l LEVEL",
-# :long => "--log_level LEVEL",
-# :description => "Set the log level (debug, info, warn, error, fatal)",
-# :required => true,
-# :proc => nil
-#
-# option :help,
-# :short => "-h",
-# :long => "--help",
-# :description => "Show this message",
-# :on => :tail,
-# :boolean => true,
-# :show_options => true,
-# :exit => 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb 2016-07-06 15:58:04.000000000 +0200
+++ new/spec/spec_helper.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,15 +0,0 @@
-$TESTING = true
-$:.push File.join(File.dirname(__FILE__), "..", "lib")
-
-require "mixlib/cli"
-
-class TestCLI
- include Mixlib::CLI
-end
-
-RSpec.configure do |config|
- config.filter_run :focus => true
- config.run_all_when_everything_filtered = true
- config.treat_symbols_as_metadata_keys_with_true_values = true
- config.warnings = true
-end