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



69
70
71
# File 'lib/asker/cli.rb', line 69

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)


79
80
81
# File 'lib/asker/cli.rb', line 79

def self.exit_on_failure?
  true
end

Instance Method Details

#check(filename) ⇒ Object



43
44
45
46
47
48
# File 'lib/asker/cli.rb', line 43

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

#file(filename) ⇒ Object



36
37
38
39
# File 'lib/asker/cli.rb', line 36

def file(filename)
  # Asker start processing input file
  Asker.start(filename)
end

#initObject



52
53
54
# File 'lib/asker/cli.rb', line 52

def init
  Asker.init
end

#new_input(dirname) ⇒ Object

Create Asker demo input files

Parameters:

  • dirname (String)

    Path to folder



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

def new_input(dirname)
  Asker.new_input(dirname)
end

#respond_to_missing?(_method_name) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/asker/cli.rb', line 73

def respond_to_missing?(_method_name)
  true
end

#versionObject



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

def version
  puts "#{Application::NAME} version #{Application::VERSION}"
end