Sha256: c7555ddf7841beeb2d5df54431dd3b63325b39b6df10a5af3aaf66e3fced56b5

Contents?: true

Size: 1.51 KB

Versions: 19

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true
require 'shopify_cli'

module Node
  module Commands
    class Generate < ShopifyCli::Command
      subcommand :Page, 'page', Project.project_filepath('commands/generate/page')
      subcommand :Billing, 'billing', Project.project_filepath('commands/generate/billing')
      subcommand :Webhook, 'webhook', Project.project_filepath('commands/generate/webhook')

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

      def self.help
        ShopifyCli::Context.message('node.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('node.generate.extended_help', ShopifyCli::TOOL_NAME)
      end

      def self.run_generate(script, name, 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('node.generate.error.generic', name)
        when 2
          ctx.message('node.generate.error.name_exists', name)
        else
          ctx.message('node.error.generic')
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
shopify-cli-1.5.0 lib/project_types/node/commands/generate.rb
shopify-cli-1.4.1 lib/project_types/node/commands/generate.rb
shopify-cli-1.4.0 lib/project_types/node/commands/generate.rb
shopify-cli-1.3.1 lib/project_types/node/commands/generate.rb
shopify-cli-1.3.0 lib/project_types/node/commands/generate.rb
shopify-cli-1.2.0 lib/project_types/node/commands/generate.rb
shopify-cli-1.1.2 lib/project_types/node/commands/generate.rb
shopify-cli-1.1.1 lib/project_types/node/commands/generate.rb
shopify-cli-1.1.0 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.5 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.4 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.3 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.2 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.1 lib/project_types/node/commands/generate.rb
shopify-cli-1.0.0 lib/project_types/node/commands/generate.rb
shopify-cli-0.9.3 lib/project_types/node/commands/generate.rb
shopify-cli-0.9.2 lib/project_types/node/commands/generate.rb
shopify-cli-0.9.1 lib/project_types/node/commands/generate.rb
shopify-cli-0.9.0 lib/project_types/node/commands/generate.rb