Class: Toga::Commands::Edit

Inherits:
Toga::Command show all
Defined in:
lib/toga/commands/edit.rb

Class Method Summary collapse

Methods included from Error

included

Class Method Details

.run!(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/toga/commands/edit.rb', line 7

def self.run!(*args)
  config = Config.load!
  if config.editor.nil?
    puts "Type the console command you use to launch your text editor (e.g. vi, emacs, vim, mate, nano...)"
    config.editor = $stdin.gets.strip
  end
  
  # Tailor arguments for specific editors
  args = []
  case config.editor
  when "mate"
    args.push "-a"
  end
  
  system "#{config.editor} #{Dir.getwd}/#{Toga::TOGAFILE_NAME} #{args.join(" ")}"
end