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



87
88
89
# File 'lib/asker/cli.rb', line 87

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)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#check(filename) ⇒ Object

Check input file syntax

Parameters:

  • filename (String)

    Path to input file



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

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

Create Asker demo input files

Parameters:

  • dirname (String)

    Path to folder



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

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

#file(filename) ⇒ Object

Create questions from input file

Parameters:

  • filename (String)

    Path to input file



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

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

#initObject

Create default INI config file



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

def init
  Asker.create_configuration
end

#respond_to_missing?(_method_name) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/asker/cli.rb', line 91

def respond_to_missing?(_method_name)
  true
end

#show_homepageObject

Show documentation homepage



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

def show_homepage()
  puts Application::HOMEPAGE
end

#versionObject

Show current version



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

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