Class: Domainr::CLI::Commands

Inherits:
Thor
  • Object
show all
Includes:
Hirb::Console
Defined in:
lib/domainr/cli/commands.rb

Instance Method Summary collapse

Instance Method Details

#info(query) ⇒ Object



11
12
13
# File 'lib/domainr/cli/commands.rb', line 11

def info(query)
  ap client.info(query)
end

#search(query) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/domainr/cli/commands.rb', line 16

def search(query)
  client.search(query).results.tap do |results|
    available, unavailable = results.map! { |res|
      res.suggestion = "#{res.domain.bold}#{res.path.underline}"
      res
    }.partition { |res| res.availability == 'available' }

    available.map! { |res| res.available = ''.green; res }
    unavailable.map! { |res| res.available = ''.red; res }

    table available + unavailable,
          fields: [:suggestion, :available],
          unicode: true
  end
end