Method: Booker#parse

Defined in:
lib/booker.rb

#parse(args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/booker.rb', line 25

def parse(args)
  # no args given, show help
  helper if args.none?

  # if arg starts with hyphen, parse option
  parse_opt args if /^-.*/.match(args.first)

  # interpret command
  browsearg = args.first

  if browsearg.match(/^[0-9]/) # bookmark
    open_bookmark args
  elsif domain.match(browsearg) # website
    puts 'opening website: ' + browsearg
    openweb(prep(browsearg))
  else
    open_search(args.join(' ').strip)
  end
end