Class: Proton::CLI
- Inherits:
-
Shake
- Object
- Shake
- Proton::CLI
- Extended by:
- Helpers
- Includes:
- Defaults
- Defined in:
- lib/proton/cli.rb,
lib/proton/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
.find_config_file ⇒ Object
226 227 228 |
# File 'lib/proton/cli.rb', line 226 def self.find_config_file Proton::CONFIG_FILES.inject(nil) { |a, fname| a ||= find_in_project(fname) } end |
.run(*argv) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/proton/cli.rb', line 184 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..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..include?(what) } else err say_error "#{e.class}: #{e.}" say_info "#{e.backtrace.first}" err say_error "Oops! An error occured." say_info "Use --trace for more info." end end end |