#!/usr/bin/env ruby $:.push File.expand_path("../../lib", __FILE__) require 'snapshot' require 'commander' require 'snapshot/snapfile_creator' require 'snapshot/snapshot_config' 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 '--snapfile PATH', String, 'Custom path for your Snapfile.' global_option '--noclean', 'Skips the clean process of the build command when running snapshot.' global_option('--verbose', 'Shows all output printed by Instruments.') { $verbose = true } always_trace! command :run do |c| c.syntax = 'snapshot' c.description = 'Take new screenshots based on the Snapfile.' c.action do |args, options| path = (Snapshot::Helper.fastlane_enabled?? './fastlane' : '.') Dir.chdir(path) do # switch the context Snapshot::DependencyChecker.check_simulators Snapshot::SnapshotConfig.shared_instance(options.snapfile) Snapshot::Runner.new.work(clean: !options.noclean) end 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| path = (Snapshot::Helper.fastlane_enabled?? './fastlane' : '.') Snapshot::SnapfileCreator.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 iOS Version you want to use' c.action do |args, options| version = options.ios || Snapshot::LatestIosVersion.version require 'snapshot/reset_simulators' Snapshot::ResetSimulators.clear_everything!(version) end end default_command :run run! end end SnapshotApplication.new.run