Class: Gym::CommandsGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



12
13
14
15
16
17
# File 'lib/gym/commands_generator.rb', line 12

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

Instance Method Details

#convert_options(options) ⇒ Object



19
20
21
22
23
# File 'lib/gym/commands_generator.rb', line 19

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

#runObject



25
26
27
28
29
30
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
# File 'lib/gym/commands_generator.rb', line 25

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

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

  command :build do |c|
    c.syntax = "gym"
    c.description = "Just builds your app"
    c.action do |_args, options|
      config = FastlaneCore::Configuration.create(Gym::Options.available_options,
                                                  convert_options(options))
      Gym::Manager.new.work(config)
    end
  end

  command :init do |c|
    c.syntax = "gym init"
    c.description = "Creates a new Gymfile for you"
    c.action do |_args, options|
      containing = (File.directory?("fastlane") ? 'fastlane' : '.')
      path = File.join(containing, Gym.gymfile_name)
      raise "Gymfile already exists".yellow if File.exist?(path)
      template = File.read("#{Helper.gem_path('gym')}/lib/assets/GymfileTemplate")
      File.write(path, template)
      Helper.log.info "Successfully created '#{path}'. Open the file using a code editor.".green
    end
  end

  default_command :build

  run!
end