Class: ApCommand::Application

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

Overview

ap_command main class.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.invoke(argv) ⇒ void

This method returns an undefined value.

execute application shortcut.

Parameters:

  • argv (Array)

    ARGV object.



40
41
42
# File 'lib/ap_command.rb', line 40

def self.invoke(argv)
  self.new.run(argv)
end

Instance Method Details

#run(argv) ⇒ void

This method returns an undefined value.

execute application.

Parameters:

  • argv (Array)

    ARGV object.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ap_command.rb', line 20

def run(argv)
  opt = OptionParser.new
  opt.on('-v', '--version') {|v| version}
  opt.on('-h', '--help') {|v| usage}
  opt.parse!(argv)

  path = argv.first.to_s
  usage("File NotFound(path=#{path})") unless(File.exists?(path))
  
  begin
    awesome(JSON.parse(File.read(path)))
  rescue JSON::ParserError => e 
    usage("Error: #{e.class} message => #{e.message}")
  end
end