Sha256: 1d18086a73eeae8ad82a42c8648dc6bf75b66c23367e68fffd80f33ec030425e

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Jets
  module Command
    class ApplicationCommand < Base # :nodoc:
      hide_command!

      self.bin = "jets" if respond_to?(:bin=) # Rails 7.1

      def help
        perform # Punt help output to the generator.
      end

      # This is:
      #
      #   bundle exec jets application:help => jets new --help
      #   bundle exec jets application      => jets new --help
      #
      def perform(*args)
        version_flags = %w[-v --version] & args
        unless version_flags.empty?
          puts "Jets #{Jets::VERSION}"
          return
        end

        # require lazily so that Rails constant is only defined within generators
        require "jets/generators/overrides/app/app_generator"
        override_exit_on_failure?
        argv = Rails::Generators::ARGVScrubber.new(args).prepare!
        Jets::Generators::AppGenerator.start argv
      end

    private
      # We override this way because Jets require generators lazily
      def override_exit_on_failure?
        Jets::Generators::AppGenerator.class_eval do
          # We want to exit on failure to be kind to other libraries
          # This is only when accessing via CLI
          def self.exit_on_failure?
            true
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/commands/application/application_command.rb
jets-5.0.12 lib/jets/commands/application/application_command.rb
jets-5.0.11 lib/jets/commands/application/application_command.rb
jets-5.0.10 lib/jets/commands/application/application_command.rb
jets-5.0.9 lib/jets/commands/application/application_command.rb