Class: Rly::Commands::Add
- Inherits:
-
Rly::Command
- Object
- Rly::Command
- Rly::Commands::Add
- Defined in:
- lib/rly/commands/add.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(name, url, options) ⇒ Add
constructor
A new instance of Add.
Methods inherited from Rly::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(name, url, options) ⇒ Add
Returns a new instance of Add.
9 10 11 12 13 |
# File 'lib/rly/commands/add.rb', line 9 def initialize(name, url, ) @name = name @url = url @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# 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 |