Class: Pilot::CommandsGenerator

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/pilot/commands_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



13
14
15
16
17
18
# File 'lib/pilot/commands_generator.rb', line 13

def self.start
  FastlaneCore::UpdateChecker.start_looking_for_update("pilot")
  new.run
ensure
  FastlaneCore::UpdateChecker.show_update_status("pilot", Pilot::VERSION)
end

Instance Method Details

#convert_options(options) ⇒ Object



20
21
22
23
24
# File 'lib/pilot/commands_generator.rb', line 20

def convert_options(options)
  o = options.__hash__.dup
  o.delete(:verbose)
  o
end

#handle_email(config, _args) ⇒ Object



26
27
28
29
# File 'lib/pilot/commands_generator.rb', line 26

def handle_email(config, _args)
  config[:email] ||= _args.first
  config[:email] ||= ask("Email address of the tester: ".yellow)
end

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/pilot/commands_generator.rb', line 31

def run
  program :version, Pilot::VERSION
  program :description, Pilot::DESCRIPTION
  program :help, "Author", "Felix Krause <[email protected]>"
  program :help, "Website", "https://fastlane.tools"
  program :help, "GitHub", "https://github.com/fastlane/pilot"
  program :help_formatter, :compact

  global_option("--verbose") { $verbose = true }

  command :upload do |c|
    c.syntax = "pilot upload"
    c.description = "Uploads a new binary to Apple TestFlight"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
      Pilot::BuildManager.new.upload(config)
    end
  end

  command :builds do |c|
    c.syntax = "pilot builds"
    c.description = "Lists all builds for given application"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
      Pilot::BuildManager.new.list(config)
    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.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)
    end
  end

  command :list do |c|
    c.syntax = "pilot list"
    c.description = "Lists all registered testers, both internal and external"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
      Pilot::TesterManager.new.list_testers(config)
    end
  end

  command :find do |c|
    c.syntax = "pilot find"
    c.description = "Find a tester (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)
    end
  end

  command :remove do |c|
    c.syntax = "pilot remove"
    c.description = "Remove an external tester 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)
    end
  end

  command :export do |c|
    c.syntax = "pilot export"
    c.description = "Exports all external testers to a CSV file"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
      Pilot::TesterExporter.new.export_testers(config)
    end
  end

  command :import do |c|
    c.syntax = "pilot import"
    c.description = "Create external testers from a CSV file"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
      Pilot::TesterImporter.new.import_testers(config)
    end
  end

  default_command :help

  run!
end