class FileReplicator::JoinerCmdParse
Protected Instance Methods
parse_argv()
click to toggle source
Parse ARGV @return Slop options
# File lib/file_replicator/joiner_cmd_parse.rb, line 10 def parse_argv Slop.parse do |o| o.string '-f', '--first', 'First file of the list to combine' o.string '-l', '--last', 'Last file of the list to combine' o.string '-o', '--output-path', 'Destination file path' o.bool '--no-progress', 'Disable progressbar' o.bool '--no-colour', 'Disable colours' o.bool '--quiet', 'Suppress output' o.on('--readme', 'Detailed description of some of the parameters and exit') { puts readme exit } o.on('--version', 'Display version information and exit') { puts VERSION exit } o.on('-h', '--help', 'Display this message') { puts o exit } end end
readme()
click to toggle source
# File lib/file_replicator/joiner_cmd_parse.rb, line 75 def readme <<-TXT README TXT end
validate(options)
click to toggle source
# File lib/file_replicator/joiner_cmd_parse.rb, line 36 def validate(options) validate_first_file options validate_last_file options end
validate_directory(options)
click to toggle source
Validates the existence of a directory @param [Slop] options @raise ArgumentError
# File lib/file_replicator/joiner_cmd_parse.rb, line 68 def validate_directory(options) unless options.output_path? msg = 'Missing output path (-o)' raise MissingArgumentException.new msg end end
validate_first_file(options)
click to toggle source
# File lib/file_replicator/joiner_cmd_parse.rb, line 41 def validate_first_file(options) unless options.first? msg = 'Missing first input file (-f)' raise MissingArgumentException.new msg end unless File.exist? options[:first] msg = "#{options[:first]} does not exist (-f)" raise ArgumentError.new msg end end
validate_last_file(options)
click to toggle source
# File lib/file_replicator/joiner_cmd_parse.rb, line 53 def validate_last_file(options) unless options.last? msg = 'Missing last input file (-l)' raise MissingArgumentException.new msg end unless File.exist? options[:last] msg = "#{options[:last]} does not exist (-l)" raise ArgumentError.new msg end end