lib/pilot/commands_generator.rb in pilot-1.3.0 vs lib/pilot/commands_generator.rb in pilot-1.4.0
- old
+ new
@@ -1,7 +1,6 @@
# rubocop:disable Metrics/MethodLength
-# rubocop:disable Metrics/AbcSize
require "commander"
require "pilot/options"
require "fastlane_core"
HighLine.track_eof = false
@@ -23,13 +22,25 @@
o = options.__hash__.dup
o.delete(:verbose)
o
end
- def handle_email(config, args)
- config[:email] ||= args.first
- config[:email] ||= ask("Email address of the tester: ".yellow)
+ def handle_multiple(action, args, options)
+ mgr = Pilot::TesterManager.new
+ config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
+ args.push(ask("Email address of the tester: ".yellow)) if args.empty?
+ failures = []
+ args.each do |address|
+ config[:email] = address
+ begin
+ mgr.public_send(action, config)
+ rescue => ex
+ failures.push(address)
+ Helper.log.info "[#{address}]: #{ex}".red
+ end
+ end
+ raise "Some operations failed: #{failures}".red unless failures.empty?
end
def run
program :version, Pilot::VERSION
program :description, Pilot::DESCRIPTION
@@ -58,15 +69,13 @@
end
end
command :add do |c|
c.syntax = "pilot add"
- c.description = "Adds a new external tester to a specific app (if given). This will also add an existing tester to an app."
+ c.description = "Adds new external tester(s) to a specific app (if given). This will also add an existing tester to an app."
c.action do |args, options|
- config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
- handle_email(config, args)
- Pilot::TesterManager.new.add_tester(config)
+ handle_multiple('add_tester', args, options)
end
end
command :list do |c|
c.syntax = "pilot list"
@@ -77,24 +86,20 @@
end
end
command :find do |c|
c.syntax = "pilot find"
- c.description = "Find a tester (internal or external) by their email address"
+ c.description = "Find tester(s) (internal or external) by their email address"
c.action do |args, options|
- config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
- handle_email(config, args)
- Pilot::TesterManager.new.find_tester(config)
+ handle_multiple('find_tester', args, options)
end
end
command :remove do |c|
c.syntax = "pilot remove"
- c.description = "Remove an external tester by their email address"
+ c.description = "Remove external tester(s) by their email address"
c.action do |args, options|
- config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
- handle_email(config, args)
- Pilot::TesterManager.new.remove_tester(config)
+ handle_multiple('remove_tester', args, options)
end
end
command :export do |c|
c.syntax = "pilot export"