Class: Node::Commands::Generate

Inherits:
ShopifyCli::Command show all
Defined in:
lib/project_types/node/commands/generate.rb,
lib/project_types/node/commands/generate/page.rb,
lib/project_types/node/commands/generate/billing.rb,
lib/project_types/node/commands/generate/webhook.rb

Defined Under Namespace

Classes: Billing, Page, Webhook

Instance Attribute Summary

Attributes inherited from ShopifyCli::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShopifyCli::Command

call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry

Methods included from ShopifyCli::Feature::Set

#hidden?, #hidden_feature

Constructor Details

This class inherits a constructor from ShopifyCli::Command

Class Method Details

.extended_helpObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/project_types/node/commands/generate.rb', line 19

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

.helpObject



15
16
17
# File 'lib/project_types/node/commands/generate.rb', line 15

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

.response(code, name, ctx) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/project_types/node/commands/generate.rb', line 39

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

.run_generate(script, name, ctx) ⇒ Object



32
33
34
35
36
37
# File 'lib/project_types/node/commands/generate.rb', line 32

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

Instance Method Details

#callObject



11
12
13
# File 'lib/project_types/node/commands/generate.rb', line 11

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