Class: CLI

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

Overview

Command Line User Interface

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



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

def method_missing(method, *_args, &_block)
  file(method.to_s)
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



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

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



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

def init
  Asker.create_configuration
end

#versionObject

Show current version



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

def version
  print Rainbow(Application::NAME).bright.blue
  puts  " (version #{Rainbow(Application::VERSION).green})"
end