lib/chef-dk/cli.rb in chef-dk-4.0.60 vs lib/chef-dk/cli.rb in chef-dk-4.1.7
- old
+ new
@@ -1,7 +1,7 @@
#
-# Copyright:: Copyright (c) 2014-2018 Chef Software Inc.
+# Copyright:: Copyright (c) 2014-2019 Chef Software 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
@@ -13,16 +13,17 @@
# 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 "mixlib/cli"
-require "chef-dk/version"
-require "chef-dk/commands_map"
-require "chef-dk/builtin_commands"
-require "chef-dk/helpers"
-require "chef-dk/ui"
+require "mixlib/cli" unless defined?(Mixlib::CLI)
+require_relative "version"
+require_relative "commands_map"
+require_relative "builtin_commands"
+require_relative "helpers"
+require_relative "ui"
+require_relative "dist"
require "chef/util/path_helper"
require "chef/mixin/shell_out"
require "bundler"
module ChefDK
@@ -39,11 +40,11 @@
BANNER
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{ChefDK::Dist::PRODUCT} version",
boolean: true
option :help,
short: "-h",
long: "--help",
@@ -93,19 +94,23 @@
end
exit 0
end
def show_version
- msg("Chef Development Kit Version: #{ChefDK::VERSION}")
-
- ["chef-client", "delivery", "berks", "kitchen", "inspec"].each do |component|
- result = Bundler.with_clean_env { shell_out("#{component} --version") }
+ msg("#{ChefDK::Dist::PRODUCT} version: #{ChefDK::VERSION}")
+ { "#{ChefDK::Dist::INFRA_CLIENT_PRODUCT}": "#{ChefDK::Dist::INFRA_CLIENT_CLI}",
+ "#{ChefDK::Dist::INSPEC_PRODUCT}": "#{ChefDK::Dist::INSPEC_CLI}",
+ "Test Kitchen": "kitchen",
+ "Foodcritic": "foodcritic",
+ "Cookstyle": "cookstyle",
+ }.each do |name, cli|
+ result = Bundler.with_clean_env { shell_out("#{cli} --version") }
if result.exitstatus != 0
- msg("#{component} version: ERROR")
+ msg("#{name} version: ERROR")
else
version = result.stdout.lines.first.scan(/(?:master\s)?[\d+\.\(\)]+\S+/).join("\s")
- msg("#{component} version: #{version}")
+ msg("#{name} version: #{version}")
end
end
end
def show_help
@@ -187,14 +192,14 @@
bin_index = paths.index(drive_upcase(Chef::Util::PathHelper.cleanpath(omnibus_bin_dir)))
if embed_index
if bin_index
if embed_index < bin_index
err("WARN: #{omnibus_embedded_bin_dir} is before #{omnibus_bin_dir} in your #{path_key}, please reverse that order.")
- err("WARN: consider using the correct `chef shell-init <shell>` command to setup your environment correctly.")
+ err("WARN: consider using the correct `#{ChefDK::Dist::EXEC} shell-init <shell>` command to setup your environment correctly.")
end
else
err("WARN: only #{omnibus_embedded_bin_dir} is present in your path, you must add #{omnibus_bin_dir} before that directory.")
- err("WARN: consider using the correct `chef shell-init <shell>` command to setup your environment correctly.")
+ err("WARN: consider using the correct `#{ChefDK::Dist::EXEC} shell-init <shell>` command to setup your environment correctly.")
end
end
end
end
end