Class: Drumknott::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/drumknott/cli.rb

Constant Summary collapse

EMPTY_CACHE =
{}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, arguments = [], name = nil, key = nil) ⇒ CLI

Returns a new instance of CLI.



8
9
10
# File 'lib/drumknott/cli.rb', line 8

def initialize(command, arguments = [], name = nil, key = nil)
  @command, @arguments, @name, @key = command, arguments, name, key
end

Class Method Details

.call(command, arguments = [], name = nil, key = nil) ⇒ Object



4
5
6
# File 'lib/drumknott/cli.rb', line 4

def self.call(command, arguments = [], name = nil, key = nil)
  new(command, arguments, name, key).call
end

Instance Method Details

#callObject



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/drumknott/cli.rb', line 12

def call
  case command
  when 'refresh'
    Drumknott::Refresh.call name, key
  when 'keys'
    Drumknott::Keys.call arguments
  else
    puts "Unknown command #{command}." unless command == 'help'
    puts "Commands are:\nrefresh: Update your site's content on Drumknott.\nkeys:    Create local file with your Drumknott credentials.\nhelp:    Display this message.\n\nExample Usage:\n$ drumknott refresh\n$ drumknott keys my-site-name my-site-key\n\nCredentials for Drumknott are expected via environment variables, or via a\n.drumknott file created using the `keys` command.\n\nDRUMKNOTT_NAME: Your site name, as registered with Drumknott.\nDRUMKNOTT_KEY:  Your API key, as provided by Drumknott.\n    MESSAGE\n  end\nend\n"