Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added few yaml output formats for show command, to help developing #55 #56

Merged
merged 1 commit into from Apr 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/xcodeproj/command/show.rb
Expand Up @@ -10,14 +10,40 @@ def self.banner
for one.}
end

def self.options
[
["--format [hash|tree_hash|raw]", "YAML output format, optional"],
].concat(super)
end

def initialize(argv)
xcodeproj_path = argv.shift_argument
@xcodeproj_path = File.expand_path(xcodeproj_path) if xcodeproj_path

if argv.option('--format')
@output_format = argv.shift_argument
end

super unless argv.empty?
end

def run
require 'yaml'

if @output_format
case @output_format.to_sym
when :hash
puts xcodeproj.to_hash.to_yaml
when :tree_hash
puts xcodeproj.to_tree_hash.to_yaml
when :raw
puts xcodeproj.to_yaml
else
raise Informative, "Unknowh format #{@output_format}!"
end
return
end

pretty_print = xcodeproj.pretty_print
sections = []
pretty_print.each do |key, value|
Expand Down