Module: Fargo::CLI::NickBrowser::InstanceMethods

Defined in:
lib/fargo/cli/nick_browser.rb

Instance Method Summary collapse

Instance Method Details

#download(file, other = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fargo/cli/nick_browser.rb', line 31

def download file, other = nil
  if file.is_a?(String)
    resolved = resolve(file).to_s
    listing = drilldown resolved, @file_list

    if listing.nil?
      puts "No file to download!: #{file}"
    elsif listing.is_a? Hash
      # Recursively download the entire directory
      listing.keys.each do |k|
        download File.join(resolved, k)
      end
    else
      client.download listing
    end
  else
    super
  end
end

#setup_consoleObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fargo/cli/nick_browser.rb', line 13

def setup_console
  super

  @fixed_completions = {}

  add_completion(/^browse\s+[^\s]*$/) { client.nicks }

  file_regex = /(?:\s+(?:[^\s,]*))+/
  add_completion(/^(?:get|download)#{file_regex}$/) { completion true }
  add_completion(/^(?:ls|cd)#{file_regex}$/) { completion }

  add_logger(:download_finished) do |message|
    if message[:file].end_with? 'files.xml.bz2'
      begin_browsing message[:nick]
    end
  end
end