Class: EditCommand

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

Instance Attribute Summary

Attributes inherited from Command

#description

Instance Method Summary collapse

Methods inherited from Command

#after_init, #before_init, default_cmd, describe, description, get_allowed_commands, #help, #initialize, load, load_all, #run, show_use, usage

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#mainObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/commands/edit.rb', line 6

def main
  if @params[:args].size != 1
    puts "ERROR: please provide a rcli app name to look up. Try 'rcli list' for a list of installed apps."
  end

  name = @params[:args][0]

  if name == 'core'
    exec "mate #{Rcli::SRC_PATH}"
    exit
  end
  
  yml_file = Rcli::RCLI_DOTFOLDER + DS + 'app_info' + DS + @params[:args][0] + '.yml'
  unless File.exists? yml_file
    puts "ERROR: That app is not installed"
    exit
  end
  
  app_info = YAML.load_file(yml_file)
  
  unless File.directory? app_info['application_root']
    puts "ERROR: The installed application's folder could not be found"
    exit
  end

  exec "$EDITOR #{app_info['application_root']}"
end