bin/snapshot in snapshot-0.4.3 vs bin/snapshot in snapshot-0.4.4

- old
+ new

@@ -1,49 +1,59 @@ #!/usr/bin/env ruby $:.push File.expand_path("../../lib", __FILE__) require 'snapshot' -require 'commander/import' +require 'commander' require 'snapshot/snapfile_creator' require 'snapshot/snapshot_config' HighLine.track_eof = false -# Commander -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 <snapshot@krausefx.com>' -program :help, 'Website', 'http://fastlane.tools' -program :help, 'GitHub', 'https://github.com/krausefx/snapshot' -program :help_formatter, :compact +class SnapshotApplication + include Commander::Methods -global_option('--verbose') { $verbose = true } + 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 <snapshot@krausefx.com>' + program :help, 'Website', 'http://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 } -default_command :run + always_trace! -command :run do |c| - c.syntax = 'snapshot' - c.description = 'Run the script, to take all the screenshots' - c.option '--snapfile STRING', String, 'Custom path for your Snapfile' - c.option '--noclean', 'Skips the clean process when running snapshot.' + 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::SnapshotConfig.shared_instance(options.snapfile) - Snapshot::Runner.new.work(clean: !options.noclean) + c.action do |args, options| + path = (Snapshot::Helper.fastlane_enabled?? './fastlane' : '.') + Dir.chdir(path) do # switch the context + Snapshot::SnapshotConfig.shared_instance(options.snapfile) + Snapshot::Runner.new.work(clean: !options.noclean) + end + end end - end -end -command :init do |c| - c.syntax = 'snapshot init' - c.description = "Creates a new Snapfile in the current directory" + 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) + c.action do |args, options| + path = (Snapshot::Helper.fastlane_enabled?? './fastlane' : '.') + Snapshot::SnapfileCreator.create(path) + end + end + + default_command :run + + run! end -end +end + +SnapshotApplication.new.run \ No newline at end of file