Module: Looks::CLI

Defined in:
lib/looks/cli.rb

Constant Summary collapse

USAGE =
<<-EOF
Usage: looks <command> [arguments]

Commands:
  add        Upload an image
  addresses  List email addresses
  config     Configure the default account
  images     List uploaded images
  rm         Remove an uploaded image
  set        Set the image for an email address

EOF
COMMANDS =
{
  'add'       => Command::Add,
  'addresses' => Command::Addresses,
  'config'    => Command::Config,
  'images'    => Command::Images,
  'rm'        => Command::Rm,
  'set'       => Command::Set
}

Class Method Summary collapse

Class Method Details

.error(message) ⇒ Object



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

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

.start(args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/looks/cli.rb', line 30

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



45
46
47
# File 'lib/looks/cli.rb', line 45

def self.usage
  abort USAGE
end