Sha256: 4b1f74e559f1d60a4173213df2a0da083ea2f018213701d3bb63464821d680fb

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true
require 'shopify_cli'

module Rails
  module Commands
    class Generate < ShopifyCli::Command
      subcommand :Webhook, 'webhook', Project.project_filepath('commands/generate/webhook')

      def call(*)
        @ctx.puts(self.class.help)
      end

      def self.help
        ShopifyCli::Context.message('rails.generate.help', ShopifyCli::TOOL_NAME)
      end

      def self.extended_help
        extended_help = "{{bold:Subcommands:}}\n"
        subcommand_registry.resolved_commands.sort.each do |name, klass|
          extended_help += "  {{cyan:#{name}}}: "

          if (subcmd_help = klass.help)
            extended_help += subcmd_help.gsub("\n  ", "\n    ")
          end
          extended_help += "\n"
        end
        extended_help += ShopifyCli::Context.message('rails.generate.extended_help', ShopifyCli::TOOL_NAME)
      end

      def self.run_generate(script, name, ctx)
        Gem.gem_path(ctx)
        stat = ctx.system(script)
        unless stat.success?
          ctx.abort(response(stat.exitstatus, name, ctx))
        end
      end

      def self.response(code, name, ctx)
        case code
        when 1
          ctx.message('rails.generate.error.generic', name)
        when 2
          ctx.message('rails.generate.error.name_exists', name)
        else
          ctx.message('rails.error.generic')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.5.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.4.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.4.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.3.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.3.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.2.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.1.2 lib/project_types/rails/commands/generate.rb
shopify-cli-1.1.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.1.0 lib/project_types/rails/commands/generate.rb