17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/aiuto.rb', line 17
def self.cli(*args)
args = args[0]
case args[0]
when "--help"
print "===== AIUTO HELP ======\n"
print "Welcome to Aiuto. Simply write \"aiuto Ruby is awesome\" and I will do a search for you on Google on some Ruby blog or website.\n"
print "Keep in mind that Google permits a maximum search of 32 words (OR is not counted as a word).\n\n"
print "-f, --filter \t Change filter followed by \"blog\", \"git\", \"docs\", \"social\", \"utility\", \"rails\", \"beginner\", or \"advanced\".\n"
print "\t Like this: \"aiuto 'rack queue' -f blog git docs.\n\n"
print "-no, --no-filter \t Use plain google\n\n"
print "-r, --no-ruby \t Remove word ruby\n\n"
print "--list \t List of the used libraries\n\n"
print "Aiuto means Help in Italian! :D\n\n"
print "========================\n"
when "--list"
print "========= AIUTO LIST ===========\n"
Aiuto_Helper::LIST.each do |k,v|
next if [:all, :no, :main].include?(k)
print "#{k.to_s.upcase}: \n"
to_table(v)
end
print "================================\n"
else
words = []
blogs = []
to_blog = false
to_word = true
no = false
ruby_word = true
args.each do |word|
case word
when "-f", "--filter"
to_blog = true
to_word = false
when "-no", "--no-filter"
to_blog = false
to_word = false
no = true
when "-r", "--no-ruby"
ruby_word = false
else
if to_word
words << word
elsif to_blog
blogs << word
end
end
end
blogs = [:main] if blogs.empty?
words = words.join(" ")
blogs = blogs.map(&:to_sym)
Aiuto.new(words).google(type: blogs, no: no, ruby: ruby_word)
end
end
|