class Rly::Commands::Add

Public Class Methods

new(name, url, options) click to toggle source
# File lib/rly/commands/add.rb, line 9
def initialize(name, url, options)
  @name = name
  @url = url
  @options = options
end

Public Instance Methods

execute(input: $stdin, output: $stdout) click to toggle source
# File lib/rly/commands/add.rb, line 15
def execute(input: $stdin, output: $stdout)
  shortcuts = Rly::Shortcuts.new
  if !shortcuts.exist?(@name) || @options[:force]
    shortcuts.create(@name, @url)
    output.puts "rly #{@name} in this directory will now open #{@url}"
  else
    output.puts "that name is used already. if you want to overwrite, use -f"
  end
end