Class: Consular::CLI

Inherits:
Thor
  • Object
show all
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)

Instance Method Summary (collapse)

Class Method Details

+ (Object) source_root

Source root for Thor to find templates



11
# File 'lib/consular/cli.rb', line 11

def self.source_root; File.expand_path('../../', __FILE__); end

Instance Method Details

- (Object) create



133
134
135
# File 'lib/consular/cli.rb', line 133

def create
  invoke :edit, [], options
end

- (Object) delete(project = nil)



154
155
156
157
# File 'lib/consular/cli.rb', line 154

def delete(project = nil)
  path = termfile_path(project)
  message_unless_file(path) { remove_file path }
end

- (Object) edit(project = nil)



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, options[:editor]
end

- (Object) init



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

- (Object) list



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

- (Object) setup(project = nil)



58
59
60
61
# File 'lib/consular/cli.rb', line 58

def setup(project = nil)
  path = termfile_path(project)
  message_unless_file(path) { valid_core.new(path).setup! }
end

- (Object) start(project = nil)



33
34
35
36
# File 'lib/consular/cli.rb', line 33

def start(project = nil)
  path = termfile_path(project)
  message_unless_file(path) { valid_core.new(path).process! }
end