Class: Consular::CLI
- Inherits:
-
Thor
- Object
- Thor
- Consular::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/consular/cli.rb
Overview
The CLI provides the command line interface for Consular. These are interfaced via the consular bin file.
Class Method Summary collapse
-
.source_root ⇒ Object
Source root for Thor to find templates.
Instance Method Summary collapse
- #create ⇒ Object
- #delete(project = nil) ⇒ Object
- #edit(project = nil) ⇒ Object
- #init ⇒ Object
- #list ⇒ Object
- #setup(project = nil) ⇒ Object
- #start(project = nil) ⇒ Object
Class Method Details
.source_root ⇒ Object
Source root for Thor to find templates
11 |
# File 'lib/consular/cli.rb', line 11 def self.source_root; File.('../../', __FILE__); end |
Instance Method Details
#create ⇒ Object
133 134 135 |
# File 'lib/consular/cli.rb', line 133 def create invoke :edit, [], end |
#delete(project = nil) ⇒ Object
154 155 156 157 |
# File 'lib/consular/cli.rb', line 154 def delete(project = nil) path = termfile_path(project) (path) { remove_file path } end |
#edit(project = nil) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/consular/cli.rb', line 112 def edit(project = nil) type = project && project =~ /\.yml$/ ? 'yml' : 'term' path = termfile_path project template "templates/example.#{type}.tt", path, :skip => true open_in_editor path, [:editor] end |
#init ⇒ Object
88 89 90 91 |
# File 'lib/consular/cli.rb', line 88 def init empty_directory Consular.global_path template 'templates/consularc.tt', File.join(ENV['HOME'],'.consularc'), :skip => true end |
#list ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/consular/cli.rb', line 71 def list say "Global scripts available: \n" Dir.glob("#{Consular.global_path}/*[^~]").each do |file| name = File.basename(file, '.term') title = file_comment(file) say " * #{name} - #{title}" end end |
#setup(project = nil) ⇒ Object
58 59 60 61 |
# File 'lib/consular/cli.rb', line 58 def setup(project = nil) path = termfile_path(project) (path) { valid_core.new(path).setup! } end |
#start(project = nil) ⇒ Object
33 34 35 36 |
# File 'lib/consular/cli.rb', line 33 def start(project = nil) path = termfile_path(project) (path) { valid_core.new(path).process! } end |