Sha256: 2206450c4f1d91874d32a257d01f810e25aeea694a0e60884d3c20f1541f6ad4

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

class EditCommand < Command
  
  description "Opens a script for editing in your editor of choice"
  usage "rcli edit <installed script> [-hv]"

  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rcli-0.1.2 lib/commands/edit.rb
rcli-0.1.0 lib/commands/edit.rb