Class: CLI

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

Overview

Command Line User Interface

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *_args, &_block) ⇒ Object

This actions are equals:

  • asker demo/foo.haml

  • asker file demo/fool.haml



93
94
95
# File 'lib/asker/cli.rb', line 93

def method_missing(method, *_args, &_block)
  file(method.to_s)
end

Class Method Details

.exit_on_failure?Boolean

Thor stop and show messages on screen on failure

Returns:

  • (Boolean)


103
104
105
# File 'lib/asker/cli.rb', line 103

def self.exit_on_failure?
  true
end

Instance Method Details

#check(filename) ⇒ Object



60
61
62
63
64
65
# File 'lib/asker/cli.rb', line 60

def check(filename)
  # Enable/disable color output
  Rainbow.enabled = false if options["color"] == false
  # Asker start processing input file
  Asker.check(filename)
end

#create_input(dirname) ⇒ Object



42
43
44
45
# File 'lib/asker/cli.rb', line 42

def create_input(dirname)
  Asker.create_input(dirname)
  exit 0
end

#file(filename) ⇒ Object



85
86
87
# File 'lib/asker/cli.rb', line 85

def file(filename)
  Asker.start(filename)
end

#initObject



22
23
24
25
# File 'lib/asker/cli.rb', line 22

def init
  Asker.init
  exit 0
end

#respond_to_missing?(_method_name) ⇒ Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/asker/cli.rb', line 97

def respond_to_missing?(_method_name)
  true
end

#versionObject



15
16
17
18
# File 'lib/asker/cli.rb', line 15

def version
  puts "#{Asker::NAME} version #{Asker::VERSION}"
  exit 0
end