Module: Stastic::Command

Extended by:
Command
Included in:
Command
Defined in:
lib/stastic/command.rb,
lib/stastic/commands/set.rb,
lib/stastic/commands/auth.rb,
lib/stastic/commands/base.rb,
lib/stastic/commands/help.rb,
lib/stastic/commands/info.rb,
lib/stastic/commands/list.rb,
lib/stastic/commands/create.rb,
lib/stastic/commands/rename.rb,
lib/stastic/commands/domains.rb,
lib/stastic/commands/preview.rb,
lib/stastic/commands/publish.rb

Defined Under Namespace

Classes: Auth, Base, Create, Domains, Help, Info, InvalidOptions, List, Preview, Publish, Rename, Set, UnknownCommand

Instance Method Summary collapse

Instance Method Details

#run(cmd, args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stastic/command.rb', line 15

def run(cmd, args)
  begin
    klass, method = parse_command(cmd)
    runner = klass.new(args)
    raise UnknownCommand unless runner.respond_to?(method)
    runner.send(method)
  rescue UnknownCommand
    puts "Invalid command `#{cmd}`. Run `stastic help` for available commands."
  rescue InvalidOptions
    puts "Invalid options for `#{cmd}`. Run `stastic help` for more information."
  end
end