Sha256: 93a9cf52a416ad63b7f54402ad7d4f22dc1c52837691ffe06c974738156fcc75

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

require "commander"
require "fastlane_core"

HighLine.track_eof = false

module Gym
  class CommandsGenerator
    include Commander::Methods

    FastlaneCore::CommanderGenerator.new.generate(Gym::Options.available_options)

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

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

    def run
      program :version, Gym::VERSION
      program :description, Gym::DESCRIPTION
      program :help, "Author", "Felix Krause <gym@krausefx.com>"
      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)
          UI.success "Successfully created '#{path}'. Open the file using a code editor."
        end
      end

      default_command :build

      run!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gym-1.4.0 lib/gym/commands_generator.rb
gym-1.3.0 lib/gym/commands_generator.rb