Module: Looks::CLI

Defined in:
lib/looks/cli.rb

Constant Summary collapse

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

Commands:
  addresses  List email addresses
  config     Configure the default account
  images     List uploaded images
  pull       Download an image
  push       Upload an image
  rm         Remove an uploaded image
  set        Set the image for an email address
  unset      Unset the image for an email address

EOF
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