Class: Diecut::CommandLine

Inherits:
Thor
  • Object
show all
Defined in:
lib/diecut/cli.rb

Class Method Summary collapse

Class Method Details

.add_kind(kind) ⇒ Object



100
101
102
103
104
105
# File 'lib/diecut/cli.rb', line 100

def self.add_kind(kind)
  desc "#{kind}", "Commands related to templating for #{kind}"
  kind_class = build_kind_subcommand(kind)
  const_set(kind.sub(/\A./){|match| match.upcase }, kind_class)
  subcommand kind, kind_class
end

.build_kind_subcommand(plugin_kind) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/diecut/cli.rb', line 85

def self.build_kind_subcommand(plugin_kind)
  mediator = Diecut.mediator(plugin_kind)
  example_ui = mediator.build_example_ui

  Class.new(Thor) do
    gen = Cli::TargetedGenerate.subclass_for(plugin_kind, mediator, example_ui)
    method_options(gen.class_options)
    register gen, "generate", "#{plugin_kind} generate TARGET", "Generate #{plugin_kind} output"

    lint = Cli::Lint.subclass_for(plugin_kind, mediator, example_ui)
    method_options(lint.class_options)
    register lint, "lint", "#{plugin_kind} lint", "Check well-formed-ness of #{plugin_kind} code generators"
  end
end