#!/usr/bin/env ruby $:.push File.expand_path("../../lib", __FILE__) require 'snapshot' require 'commander' HighLine.track_eof = false class SnapshotApplication include Commander::Methods def run program :version, Snapshot::VERSION program :description, 'CLI for \'snapshot\' - Automate taking localized screenshots of your iOS app on every device' program :help, 'Author', 'Felix Krause ' program :help, 'Website', 'https://fastlane.tools' program :help, 'GitHub', 'https://github.com/krausefx/snapshot' program :help_formatter, :compact global_option('--verbose', 'Shows a more verbose output') { $verbose = true } always_trace! FastlaneCore::CommanderGenerator.new.generate(Snapshot::Options.available_options) command :run do |c| c.syntax = 'snapshot' c.description = 'Take new screenshots based on the Snapfile.' c.action do |args, options| o = options.__hash__.dup o.delete(:verbose) Snapshot.config = FastlaneCore::Configuration.create(Snapshot::Options.available_options, o) Snapshot::DependencyChecker.check_simulators Snapshot::Runner.new.work end end command :init do |c| c.syntax = 'snapshot init' c.description = "Creates a new Snapfile in the current directory" c.action do |args, options| require 'snapshot/setup' path = (Snapshot::Helper.fastlane_enabled? ? './fastlane' : '.') Snapshot::Setup.create(path) end end command :reset_simulators do |c| c.syntax = 'snapshot reset_simulators' c.description = "This will remove all your existing simulators and re-create new ones" c.option '-i', '--ios String', String, 'The comma separated list of iOS Versions you want to use' c.action do |args, options| versions = [Snapshot::LatestIosVersion.version] versions = options.ios.split(',') if options.ios require 'snapshot/reset_simulators' Snapshot::ResetSimulators.clear_everything!(versions) end end default_command :run run! end end begin FastlaneCore::UpdateChecker.start_looking_for_update('snapshot') SnapshotApplication.new.run ensure FastlaneCore::UpdateChecker.show_update_status('snapshot', Snapshot::VERSION) end