public
Description: Go plugins used by sbraford. Feel free to clone individually or as a whole.
Homepage:
Clone URL: git://github.com/sbraford/go-plugins.git
go-plugins / symlink.rb
100644 19 lines (17 sloc) 0.483 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Symlink < Go::Plugin
  call_with 'symlink'
  usage 'symlink <existing_file_or_dir> <new_symlink_of_file_or_dir>'
  
  def run
    if @options.params.size < 2
      puts "Please provide an existing dir/file and target."
    else
      @existing = @options.params[0]
      @target = @options.params[1]
      if !File.exist?(@existing)
        puts "#{@existing} does not exist"; return
      end
      @cmd = "ln -s #{@existing} #{@target}"
      system(@cmd)
    end
  end
end