Module: Looks::CLI

Defined in:
lib/looks/cli.rb

Constant Summary collapse

USAGE =
"Usage: looks <command> [arguments]\n\nCommands:\n  addresses  List email addresses\n  config     Configure the default account\n  images     List uploaded images\n  pull       Download an image\n  push       Upload an image\n  rm         Remove an uploaded image\n  set        Set the image for an email address\n  unset      Unset the image for an email address\n\n"
COMMANDS =
{
  'addresses' => Command::Addresses,
  'config'    => Command::Config,
  'images'    => Command::Images,
  'pull'      => Command::Pull,
  'push'      => Command::Push,
  'rm'        => Command::Rm,
  'set'       => Command::Set,
  'unset'     => Command::Unset
}

Class Method Summary collapse

Class Method Details

.error(message) ⇒ Object



53
54
55
# File 'lib/looks/cli.rb', line 53

def self.error(message)
  abort "looks: error: #{message}"
end

.start(args) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/looks/cli.rb', line 34

def self.start(args)
  usage if args.empty?

  command = args.shift
  usage unless COMMANDS.include? command

  config = Config.load

  begin
    COMMANDS[command].new(config).run(args)
  rescue Error => e
    error(e)
  end
end

.usageObject



49
50
51
# File 'lib/looks/cli.rb', line 49

def self.usage
  abort USAGE
end