class Rbd::Cli
Attributes
args[R]
cmd[R]
flags[R]
Public Class Methods
new()
click to toggle source
# File lib/rbd/cli.rb, line 12 def initialize @flags = OpenStruct.new @args = ARGV.clone opt_parser.parse!(@args, into: flags) @cmd = @args.shift || "run" end
Public Instance Methods
load!(*files)
click to toggle source
# File lib/rbd/cli.rb, line 39 def load!(*files) file, *files = files return if file.nil? load "#{Dir.pwd}/#{file}.rb" file rescue LoadError load!(*files) end
opt_parser()
click to toggle source
# File lib/rbd/cli.rb, line 33 def opt_parser @opt_parser ||= OptionParser.new do |op| op.on("-h", "--help", "Displays help") end end
run!()
click to toggle source
# File lib/rbd/cli.rb, line 19 def run! return puts "Todo: help" if flags.help case cmd when "run" raise Rbd::NoMainError unless load! "main", "lib/main" else puts "Not a valid command: #{cmd}" end rescue Rbd::NoMainError puts "Could not run project. Expected main.rb file" end