Sha256: 871b5e9311c0debc0f3cb83f6786b6273b55fd32b7377ac234f6ea5e54460760

Contents?: true

Size: 1.37 KB

Versions: 11

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

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-1.14.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.13.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.13.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.12.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.11.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.10.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.9.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.9.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.8.0 lib/project_types/rails/commands/generate.rb
shopify-cli-1.7.1 lib/project_types/rails/commands/generate.rb
shopify-cli-1.7.0 lib/project_types/rails/commands/generate.rb