Module: SpotifyCli

Defined in:
lib/spotify_cli.rb,
lib/spotify_cli/api.rb,
lib/spotify_cli/app.rb,
lib/spotify_cli/version.rb

Defined Under Namespace

Classes: Api, App

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.call(args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/spotify_cli.rb', line 6

def self.call(args)
  mappings = {
    'next' => :next,
    'n' => :next,
    'previous' => :previous,
    'pr' => :previous,
    'set_pos' => :set_pos,
    'pos' => :set_pos,
    'replay' => :replay,
    'rep' => :replay,
    'restart' => :replay,
    'pause' => :pause,
    'stop' => :pause,
    'play' => :play_pause,
    'p' => :play_pause,
    'play_pause' => :play_pause,
    'status' => :status,
    's' => :status,
    'help' => :help
  }

  if args.empty?
    SpotifyCli::Api.status
  else
    mapping = mappings[args.first]
    if mapping.nil? || mapping == :help
      SpotifyCli::Api.help(mappings)
    else
      SpotifyCli::Api.send(mapping)
    end
  end
end