class ChefCLI::Command::Env

def gem_environment

def gem_environment
  h = {}
  h["GEM ROOT"] = omnibus_env["GEM_ROOT"]
  h["GEM HOME"] = omnibus_env["GEM_HOME"]
  h["GEM PATHS"] = omnibus_env["GEM_PATH"].split(File::PATH_SEPARATOR)
rescue OmnibusInstallNotFound
  h["GEM_ROOT"] = ENV["GEM_ROOT"] if ENV.key?("GEM_ROOT")
  h["GEM_HOME"] = ENV["GEM_HOME"] if ENV.key?("GEM_HOME")
  h["GEM PATHS"] = ENV["GEM_PATH"].split(File::PATH_SEPARATOR) if ENV.key?("GEM_PATH") && !ENV.key?("GEM_PATH").nil?
ensure
  h
end

def initialize(*args)

def initialize(*args)
  super
  @ui = UI.new
end

def paths

def paths
  omnibus_env["PATH"].split(File::PATH_SEPARATOR)
rescue OmnibusInstallNotFound
  ENV["PATH"].split(File::PATH_SEPARATOR)
end

def policyfile_config

def policyfile_config
  {}.tap do |h|
    h["Cache Path"] = CookbookOmnifetch.cache_path
    h["Storage Path"] = CookbookOmnifetch.storage_path.to_s
  end
end

def ruby_info

def ruby_info
  {}.tap do |ruby|
    ruby["Executable"] = Gem.ruby
    ruby["Version"] = RUBY_VERSION
    ruby["RubyGems"] = {}.tap do |rubygems|
      rubygems["RubyGems Version"] = Gem::VERSION
      rubygems["RubyGems Platforms"] = Gem.platforms.map(&:to_s)
      rubygems["Gem Environment"] = gem_environment
    end
  end
end

def run(params)

def run(params)
  info = {}
  info["#{ChefCLI::Dist::PRODUCT}"] = workstation_info
  info["Ruby"] = ruby_info
  info["Path"] = paths
  ui.msg info.to_yaml
end

def workstation_info

def workstation_info
  info = {}
  if omnibus_install?
    info["Version"] = ChefCLI::VERSION
    info["Home"] = package_home
    info["Install Directory"] = omnibus_root
    info["Policyfile Config"] = policyfile_config
  else
    info["Version"] = "Not running from within Workstation"
  end
  info
end