#!/usr/bin/env ruby if $PROGRAM_NAME == __FILE__ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__) require 'rubygems' require 'bundler/setup' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) end require 'claide' require 'cocoapods-playgrounds/generate' require 'cocoapods-playgrounds/gem_version' class PlainInformative < StandardError include CLAide::InformativeError end class Informative < PlainInformative def message "[!] #{super}".ansi.red end end AVAILABLE = Pod::PlaygroundGenerator.platforms.join(', ') DEFAULT = :osx class Command < CLAide::Command self.command = 'playground' self.description = 'Generate Xcode Playgrounds' self.version = CocoapodsPlaygrounds::VERSION self.arguments = [CLAide::Argument.new('NAME', true)] def self.options [ ['--platform', "Platform to generate for (default: #{DEFAULT}, available: #{AVAILABLE})"] ] end def initialize(argv) @name = argv.shift_argument @platform = argv.option('platform', DEFAULT).to_sym super end def validate! help! 'Please specify a name for your Playground' if @name.nil? end def run generator = Pod::PlaygroundGenerator.new(@platform) generator.generate(@name) end end Command.run(ARGV)