Class: CLI
- Inherits:
-
Thor
- Object
- Thor
- CLI
- Defined in:
- lib/asker/cli.rb
Overview
Command Line User Interface
Instance Method Summary collapse
-
#check(filename) ⇒ Object
Check input file syntax.
-
#file(filename) ⇒ Object
Create questions from input file.
-
#init ⇒ Object
Create default INI config file.
-
#method_missing(method, *_args, &_block) ⇒ Object
This actions are equals: * asker demo/foo.haml * asker file demo/fool.haml.
-
#version ⇒ Object
Show current version.
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
82 83 84 |
# File 'lib/asker/cli.rb', line 82 def method_missing(method, *_args, &_block) file(method.to_s) end |
Instance Method Details
#check(filename) ⇒ Object
Check input file syntax
71 72 73 74 75 76 |
# File 'lib/asker/cli.rb', line 71 def check(filename) # Enable/disable color output Rainbow.enabled = false if ['color'] == false # Asker start processing input file Asker.check(filename) end |
#file(filename) ⇒ Object
Create questions from input file
44 45 46 47 48 49 |
# File 'lib/asker/cli.rb', line 44 def file(filename) # Enable/disable color output Rainbow.enabled = false if ['color'] == false # Asker start processing input file Asker.new.start(filename) end |
#init ⇒ Object
Create default INI config file
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/asker/cli.rb', line 55 def init src = File.join(File.dirname(__FILE__), 'files', 'config.ini') dst = File.join(Dir.pwd, 'config.ini') if File.exist? dst puts "[WARN] Exists file! => #{Rainbow(File.basename(dst)).yellow.bright}" else FileUtils.cp(src, dst) puts "[ OK ] Create file => #{Rainbow(File.basename(dst)).green}" end end |
#version ⇒ Object
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 |