class ByebugCleaner::ArgumentParser::Options
Attributes
backup[RW]
dir[RW]
test[RW]
Public Class Methods
new()
click to toggle source
# File lib/byebug/cleaner/parser.rb, line 7 def initialize self.dir = "app" self.backup = true self.test = 0 end
Public Instance Methods
boolean_backup_option(parser)
click to toggle source
# File lib/byebug/cleaner/parser.rb, line 56 def boolean_backup_option(parser) # Boolean switch. parser.on("-b", "--[no-]backup", "Backup files") do |b| self.backup = b end end
define_options(parser)
click to toggle source
# File lib/byebug/cleaner/parser.rb, line 13 def define_options(parser) parser.banner = "Usage: rake byebug:clean -- [options]" parser.separator "Task recursively search files where 'byebug' uses and remove this line from file." parser.separator "" parser.separator "Default options:" parser.separator " Dir - {RAILS_APP}/app" parser.separator " Backup - true" parser.separator "" parser.separator "Specific options:" # add additional options dir_option(parser) boolean_backup_option(parser) parser.separator "" parser.separator "Common options:" # No argument, shows at tail. This will print an options summary. # Try it and see! parser.on("-h", "--help", "Prints this help") do puts parser exit end # Another typical switch to print the version. parser.on("-v", "Show version") do puts VERSION exit end parser.separator "" parser.separator "Examples:" parser.separator " rake byebug:clean" parser.separator " rake byebug:clean -- -dspec" parser.separator " rake byebug:clean -- --dir=app/models --no-debug" end
dir_option(parser)
click to toggle source
# File lib/byebug/cleaner/parser.rb, line 48 def dir_option(parser) # Cast 'time' argument to a Time object. parser.on("-dDIR", "--dir=DIR", String, "Set dir for searching") do |dir| self.dir = dir end end