Class: Barnyard2::Waldo::CLI
- Inherits:
-
Object
- Object
- Barnyard2::Waldo::CLI
- Defined in:
- lib/barnyard2waldo/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/barnyard2waldo/cli.rb', line 13 def initialize = {} [:utc] = Barnyard2::Waldo::Defaults::UTC [:bookmark] = Barnyard2::Waldo::Defaults::Bookmark opt_parser = OptionParser.new do |opt| opt. = "Usage: waldo [OPTIONS]" opt.on("-b", "--bookmark [waldofile]", "Bookmark file", " Default: #{[:bookmark]}") do |value| [:bookmark] = value end opt.on("-z", "--zulu", "Print Zulu time (utc)", " Default: #{[:utc]}") do |value| [:utc] = value end opt.separator "Options::" opt.on_tail("-h", "--help", "Display this screen") do puts opt_parser exit 0 end end #Verify the options begin # raise unless ARGV.size > 0 opt_parser.parse! #If options fail display help #rescue Exception => e # puts e.message # puts e.backtrace.inspect rescue puts opt_parser exit end begin finder = Barnyard2::Waldo::Where.new([:bookmark]) finder.utc = [:utc] puts finder rescue Barnyard2::Waldo::WaldoFilePermissionsError abort "Waldo File Read Perrmission Error, check permissions on the bookmark file." rescue Barnyard2::Waldo::WaldoFileError abort "Waldo File Error, file may not exist." end end |
Class Method Details
.invoke ⇒ Object
9 10 11 |
# File 'lib/barnyard2waldo/cli.rb', line 9 def self.invoke self.new end |