Class: Drumknott::CLI

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

Constant Summary collapse

EMPTY_CACHE =
{}.freeze
HELP_MESSAGE =
<<-MESSAGE
Commands are:
refresh: Update your site's content on Drumknott.
keys:    Create local file with your Drumknott credentials.
help:    Display this message.

Example Usage:
$ drumknott refresh
$ drumknott keys my-site-name my-site-key

Credentials for Drumknott are expected via environment variables, or
via a .drumknott file created using the `keys` command.

DRUMKNOTT_NAME: Your site name, as registered with Drumknott.
DRUMKNOTT_KEY:  Your API key, as provided by Drumknott.
MESSAGE

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CLI.



28
29
30
31
32
33
34
35
36
# File 'lib/drumknott/cli.rb', line 28

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

Class Method Details

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



22
23
24
25
26
# File 'lib/drumknott/cli.rb', line 22

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

Instance Method Details

#callObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/drumknott/cli.rb', line 38

def call
  case command
  when "refresh"
    Drumknott::Refresh.call name, key, include_pages?
  when "keys"
    Drumknott::Keys.call arguments
  else
    puts "Unknown command #{command}." unless command == "help"
    puts HELP_MESSAGE
  end
end