class Xcodeproj::Command::Show

Public Class Methods

new(argv) click to toggle source
Calls superclass method Xcodeproj::Command::new
# File lib/xcodeproj/command/show.rb, line 16
def initialize(argv)
  self.xcodeproj_path = argv.shift_argument
  @output_format = argv.option('format')
  @output_format &&= @output_format.to_sym
  super
end
options() click to toggle source
Calls superclass method
# File lib/xcodeproj/command/show.rb, line 6
def self.options
  [
    ['--format=[hash|tree_hash|raw]', 'YAML output format'],
  ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/xcodeproj/command/show.rb, line 31
def run
  require 'yaml'

  if @output_format
    case @output_format
    when :hash
      puts xcodeproj.to_hash.to_yaml
    when :tree_hash
      puts xcodeproj.to_tree_hash.to_yaml
    when :raw
      puts xcodeproj.to_yaml
    end
    return
  end

  pretty_print = xcodeproj.pretty_print
  sections = []
  pretty_print.each do |key, value|
    section = key.green
    yaml = value.to_yaml
    yaml.gsub!(/^---$/, '')
    yaml.gsub!(/^-/, "\n-")
    yaml.prepend(section)
    sections << yaml
  end
  puts sections * "\n\n"
end
validate() click to toggle source
Calls superclass method
# File lib/xcodeproj/command/show.rb, line 23
def validate
  super
  unless [nil, :hash, :tree_hash, :raw].include?(@output_format)
    help! "Unknown format `#{@output_format}`"
  end
  open_project!
end