Class: Kikeru::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/kikeru/command.rb

Constant Summary collapse

USAGE =
"Usage: kikeru [OPTION]... [FILE]..."

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommand

Returns a new instance of Command.



17
18
19
# File 'lib/kikeru/command.rb', line 17

def initialize
  @logger = Kikeru::Logger.new
end

Class Method Details

.run(*arguments) ⇒ Object



12
13
14
# File 'lib/kikeru/command.rb', line 12

def run(*arguments)
  new.run(arguments)
end

Instance Method Details

#run(arguments) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kikeru/command.rb', line 21

def run(arguments)
  if /\A(-h|--help)\z/ =~ arguments[0]
    write_help_message
    exit(true)
  elsif /\A(-v|--version)\z/ =~ arguments[0]
    write_version_message
    exit(true)
  end

  files = files_from_arguments(arguments)
  file_container = Kikeru::Container.new(files)

  if file_container.empty?
    write_empty_message
    exit(false)
  end

  window = Kikeru::Window.new
  window.add_container(file_container)
  window.show_all
  window.load

  Gtk.main
end