class Birdwatcher::Commands::Resource
Public Class Methods
detailed_usage()
click to toggle source
# File lib/birdwatcher/commands/resource.rb, line 10 def self.detailed_usage <<-USAGE The #{'resource'.bold} command can be used to execute commands from a file on disk. Resource files are simple text-based files containing one command per line. They can be very convenient for common or repetitive workflows. #{'USAGE:'.bold} #{'Execute commands from a resource file:'.bold} resource FILE USAGE end
Public Instance Methods
run()
click to toggle source
# File lib/birdwatcher/commands/resource.rb, line 23 def run if !arguments? error("You must provide a path to a resource file") return false end filepath = File.expand_path(arguments.join(" ")) if !File.exists?(filepath) error("File #{filepath.bold} does not exist") return false end if !File.readable?(filepath) error("File #{filepath} is not readable") return false end File.read(filepath).each_line do |command| command.strip! next if command.empty? || command.start_with?("#") || command.start_with?("//") console.handle_input(command.strip) end end