Module: Command

Defined in:
lib/robbie/command.rb

Overview

Request.book(‘book name’)

Class Method Summary collapse

Class Method Details

.help(*args) ⇒ Object



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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/robbie/command.rb', line 42

def help(*args)
  unless args.empty?
    @args = args.first
    @command = @args.first
  end

  if @command.nil?
    advice = {
      search:   'searches the query and returns the first 3 results',
      info:     'provides extensive information on the query (ID)',
      version:  'returns the current version',
      help:     'return this help menu'
    }

    puts "usage: robbie [command] [arguments]"
    advice.map do |key, value|
      puts "#{key}\t\t#{value}"
    end
    exit
  else

    info = {
      search: {
        command: 'search',
        example: 'robbie search movies "Pulp Fiction"',
        description: 'searches the query and returns the first 3 results'
      },
      info: {
        command: 'info',
        example: 'robbie info tt0110912',
        description: 'provides extensive information on the query (ID)'
      },
      version: {
        command: 'version',
        example: 'robbie version',
        description: 'returns the current version',
      },
      help: {
        command: 'help',
        example: 'robbie help search',
        description: 'return this help menu. if an optional command parameter is provided, a description and exmaple is returned'
      }
    }

    if info.has_key? @command.to_sym
      symInfo = info[@command.to_sym]
      puts Rainbow("robbie #{symInfo[:command]}\n").white.bg(:black)
      puts "Example: $ #{symInfo[:example]}\n"
      puts "Description: #{symInfo[:description]}"
    else
      puts "No manual entry for #{@command}"
    end

  end
end

.info(*args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/robbie/command.rb', line 24

def info(*args)
  @args = args.first
  @command = @args.shift

  if @command.nil? then help end

  case @command
  when 'movie' then Request.movie(@args)
  when 'tv' then Request.tv(@args)
  when 'actor' then Request.actor(@args)
  when 'book' then Request.book(@args)
  when 'song' then Request.song(@args)
  when 'album' then Request.album(@args)
  when 'artist' then Request.artist(@args)
  when 'id' then Request.id(@args) # currently only works for movie and tv show
  else help end
end

.search(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/robbie/command.rb', line 11

def search(*args)
  @args = args.first
  @command = @args.shift

  if @command.nil? then help end

  case @command
  when 'movie' then Search.movie(@args)
  when 'tv' then Search.tv(@args)
  when 'actor' then Search.actor(@args)
  else help end
end