Sha256: bb990d46c73b8b3d3c7413df534cc28a89c3dd7fc1a3151f746a425f490b9b0f

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

require 'potassium/cli_options'

module Potassium::CLI
  extend Potassium::CliOptions

  desc "Create a new Potassium Rails project."
  arg 'app_path'
  command :create do |c|
    c.default_desc "Create a new project."
    c.switch "version-check",
      default_value: true,
      desc: "Performs a version check before running.",
      negatable: true

    create_options.each { |opts| c.send(opts.delete(:type), opts.delete(:name), opts) }

    c.action do |_global_options, options, _args|
      require "potassium/newest_version_ensurer"

      begin_creation = -> do
        require "potassium/generators/application"
        require "potassium/template_finder"

        template_finder = Potassium::TemplateFinder.new
        template = template_finder.default_template
        template.cli_options = options
        template.source_paths << Rails::Generators::AppGenerator.source_root
        template.start
      end

      if options["version-check"]
        ensurer = Potassium::NewestVersionEnsurer.new
        ensurer.ensure(&begin_creation)
      else
        begin_creation.call
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
potassium-5.2.3 lib/potassium/cli/commands/create.rb
potassium-5.2.2 lib/potassium/cli/commands/create.rb
potassium-5.2.1 lib/potassium/cli/commands/create.rb
potassium-5.2.0 lib/potassium/cli/commands/create.rb
potassium-5.1.4 lib/potassium/cli/commands/create.rb
potassium-5.1.3 lib/potassium/cli/commands/create.rb
potassium-5.1.2 lib/potassium/cli/commands/create.rb
potassium-5.1.1 lib/potassium/cli/commands/create.rb
potassium-3.0.0 lib/potassium/cli/commands/create.rb