domainr-cli2 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c9f44b02db0f51121cd2f0a6c3890284fb0a68d
4
- data.tar.gz: 0504e6ba3a941ca704dc275e82abbd680c39723f
3
+ metadata.gz: c5d6ccab30bc5e335a2af8d9631f40f9f202b2c4
4
+ data.tar.gz: f6740d9c27d71577609e7dd0294d68c2bcdc8fae
5
5
  SHA512:
6
- metadata.gz: de6c6d78ef07665c9baed2e4da9a8c9a6f98cd305b068321b25dfce140d8b1978dded7269e494f20693ffd38f89936d184672ed5f94187f2ca70aa68bab176a4
7
- data.tar.gz: 717bcdaf6882ae69e6305d4df3122c2c53589f05171e72cf944e3d1806f93d9bc34260691a0b0879ae03be5acde94ced53704b2970562e537cca87ec9b97ae94
6
+ metadata.gz: ccf1e7d7af0fdabd6787eb96d512259776a5308abc5837ba0896a1847c5ce06e88a940f49ea1b967b174ac8f85c195bb92dc7f8d7e5c34d685039edf7b399d06
7
+ data.tar.gz: 03fb8a176764f6f88052a787d0af5f3d73e7895d9fb7b6c3a93b1bddcea5ccc2351c15861d2f5ed40faa8f6303ce9713048a39f4d2fe2aee71685bad9fc53093
data/README.md CHANGED
@@ -6,7 +6,9 @@ Search for domains using [Domainr](https://domainr.com/) from the command line.
6
6
 
7
7
  Install with:
8
8
 
9
- $ gem install domainr-cli2
9
+ ```
10
+ $ gem install domainr-cli2
11
+ ```
10
12
 
11
13
  ## Setup
12
14
 
@@ -14,29 +16,33 @@ Install with:
14
16
 
15
17
  Once you have your key, set it once and forget it:
16
18
 
17
- $ domainr api_key <your-api-key-here>
19
+ ```
20
+ $ domainr api_key <your-api-key-here>
21
+ ```
18
22
 
19
23
  ## Usage
20
24
 
21
25
  Use the `search` command to look for domains:
22
26
 
23
- $ domainr search awesomeness
24
- +-------------+-----------------+------------------------+
25
- | Status | Domain | Path |
26
- +-------------+-----------------+------------------------+
27
- | UNAVAILABLE | awesomeness.com | http://awesomeness.com |
28
- | UNAVAILABLE | awesomeness.net | http://awesomeness.net |
29
- | DELETING | awesomeness.org | http://awesomeness.org |
30
- | UNAVAILABLE | awesomeness.us | http://awesomeness.us |
31
- | UNAVAILABLE | awesomen.es | http://awesomen.es/s |
32
- | UNKNOWN | awesome.ne | http://awesome.ne/ss |
33
- | PREMIUM | aweso.men | http://aweso.men/ess |
34
- | UNAVAILABLE | aweso.me | http://aweso.me/ness |
35
- | UNAVAILABLE | awes.om | http://awes.om/eness |
36
- | UNAVAILABLE | awe.so | http://awe.so/meness |
37
- | UNAVAILABLE | aw.es | http://aw.es/omeness |
38
- | UNAVAILABLE | aw | http://aw/esomeness |
39
- +-------------+-----------------+------------------------+
27
+ ```
28
+ $ domainr search awesomeness
29
+ +-------------+-----------------+------------------------+
30
+ | Status | Domain | Path |
31
+ +-------------+-----------------+------------------------+
32
+ | UNAVAILABLE | awesomeness.com | http://awesomeness.com |
33
+ | UNAVAILABLE | awesomeness.net | http://awesomeness.net |
34
+ | DELETING | awesomeness.org | http://awesomeness.org |
35
+ | UNAVAILABLE | awesomeness.us | http://awesomeness.us |
36
+ | UNAVAILABLE | awesomen.es | http://awesomen.es/s |
37
+ | UNKNOWN | awesome.ne | http://awesome.ne/ss |
38
+ | PREMIUM | aweso.men | http://aweso.men/ess |
39
+ | UNAVAILABLE | aweso.me | http://aweso.me/ness |
40
+ | UNAVAILABLE | awes.om | http://awes.om/eness |
41
+ | UNAVAILABLE | awe.so | http://awe.so/meness |
42
+ | UNAVAILABLE | aw.es | http://aw.es/omeness |
43
+ | UNAVAILABLE | aw | http://aw/esomeness |
44
+ +-------------+-----------------+------------------------+
45
+ ```
40
46
 
41
47
  ## Contributing
42
48
 
@@ -3,4 +3,4 @@
3
3
  require "bundler/setup"
4
4
  require "domainr/cli2"
5
5
 
6
- Domainr::CLI2::Base.start(ARGV)
6
+ Domainr::CLI2::Base.start(Domainr::CLI2::Base.rewrite_arguments(ARGV))
@@ -2,14 +2,29 @@ module Domainr
2
2
  module CLI2
3
3
  class Base < Thor
4
4
  API_KEY_STORAGE_LOCATION = '~/.domainr-cli2'.freeze
5
+ DEFAULT_COMMAND = 'search'.freeze
6
+ STATUS_FETCH_PREFIX = 'Fetching status... '.freeze
5
7
 
6
8
  class_option :verbose, type: :boolean, default: false
7
9
  class_option :status, type: :boolean, default: true
8
10
 
11
+ def self.rewrite_arguments(arguments)
12
+ options_removed = arguments.reject { |a| a =~ /^\-/ }
13
+ arguments.unshift(DEFAULT_COMMAND) if options_removed.count == 1 && !Domainr::CLI2::Base.commands.keys.include?(options_removed.first)
14
+ arguments
15
+ end
16
+
17
+ desc 'version', 'print the version number'
18
+ def version
19
+ puts Domainr::CLI2::VERSION
20
+ end
21
+
9
22
  desc "search TERM", "Execute a fuzzy search for domains like TERM"
10
23
  def search(name)
11
24
  results = client.search(name)
12
25
  if results.any?
26
+ puts "Found #{results.count.to_s.green} possible domains."
27
+ print_and_flush STATUS_FETCH_PREFIX if options[:status]
13
28
  puts results_table(results)
14
29
  else
15
30
  puts "Nothing available for that."
@@ -51,8 +66,8 @@ module Domainr
51
66
 
52
67
  def results_table(results)
53
68
  ::Terminal::Table.new headings: %w(Status Domain Path) do |table|
54
- results.each do |result|
55
- status = options[:status] ? get_status(result.domain) : nil
69
+ results.each.with_index do |result, index|
70
+ status = options[:status] ? get_status(result.domain, index+1, results.count) : nil
56
71
  table.add_row [
57
72
  colorize_status(status),
58
73
  result.domain,
@@ -99,15 +114,21 @@ module Domainr
99
114
  :red
100
115
  when :inactive
101
116
  :green
102
- when :priced
117
+ when :priced, :marketed
103
118
  :yellow
104
119
  else
105
120
  :to_s
106
121
  end
107
122
  end
108
123
 
109
- def get_status(domain)
124
+ def print_and_flush(text)
125
+ print "#{text}\r"
126
+ $stdout.flush
127
+ end
128
+
129
+ def get_status(domain, current, total)
110
130
  debug "Fetching status for: #{domain.inspect}"
131
+ print_and_flush "#{STATUS_FETCH_PREFIX} #{current}/#{total}" if options[:status]
111
132
  client.status(domain).first
112
133
  end
113
134
 
@@ -1,5 +1,5 @@
1
1
  module Domainr
2
2
  module CLI2
3
- VERSION = "0.1.1"
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domainr-cli2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Bielinski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor