Class: Hyde::CLI

Inherits:
Shake
  • Object
show all
Extended by:
Helpers
Includes:
Defaults
Defined in:
lib/hyde/cli.rb,
lib/hyde/cli/helpers.rb

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Methods included from Helpers

gem_name, no_project, other_tasks, project, project?, say_error, say_info, say_status, show_help_for, show_needed_gem, tasks_for

Class Method Details

.run(*argv) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/hyde/cli.rb', line 154

def self.run(*argv)
  return invoke(:version)  if argv == ['-v'] || argv == ['--version']
  trace = (!!argv.delete('--trace'))


  begin
    super *argv

  rescue SyntaxError => e
    raise e  if trace
    err
    say_error e.message.split("\n").last
    err
    say_error "You have a syntax error."
    say_info "Use --trace for more info."

  # Convert 'can't load redcloth' to a friendly 'please gem install RedCloth'
  rescue LoadError => e
    raise e  if trace
    show_needed_gem gem_name(e)

  # Print generic errors as something friendlier
  rescue => e
    raise e  if trace

    # Can't assume that HAML is always available.
    if Object.const_defined?(:Haml) && e.is_a?(Haml::Error)
      # Convert HAML's "Can't run XX filter; required 'yy'" messages
      # to something friendlier
      needed = %w(rdiscount stringio sass/plugin redcloth)
      needed.detect { |what| show_needed_gem(what) && true  if e.message.include?(what) }
    else
      err
      say_error "#{e.class}: #{e.message}"
      say_info "#{e.backtrace.first}"
      err
      say_error "Oops! An error occured."
      say_info "Use --trace for more info."
    end
  end
end

.run!(options = {}) ⇒ Object



196
197
198
199
200
# File 'lib/hyde/cli.rb', line 196

def self.run!(options={})
  @hydefile = options[:file]
  project rescue nil
  super *[]
end