Class: Rly::Commands::List

Inherits:
Rly::Command show all
Defined in:
lib/rly/commands/list.rb

Instance Method Summary collapse

Methods inherited from Rly::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(options) ⇒ List

Returns a new instance of List.



9
10
11
# File 'lib/rly/commands/list.rb', line 9

def initialize(options)
  @options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rly/commands/list.rb', line 13

def execute(input: $stdin, output: $stdout)
  shortcuts = Rly::Shortcuts.new
  if shortcuts.all.empty?
    output.puts "no shortcuts added yet for current directory (#{Dir.pwd})"
  else
    shortcuts.all.each do |name, url|
      output.puts "#{name} => #{url}\n"
    end
  end
end