Class: Ffsr::Mainclass
- Inherits:
-
Object
- Object
- Ffsr::Mainclass
- Defined in:
- lib/ffsr.rb
Overview
main program begins here
Instance Method Summary collapse
-
#ConditionalExit(options) ⇒ Object
ConditionalExit This function exits program if there were command line errors.
- #main ⇒ Object
Instance Method Details
#ConditionalExit(options) ⇒ Object
ConditionalExit This function exits program if there were command line errors
68 69 70 71 72 73 |
# File 'lib/ffsr.rb', line 68 def ConditionalExit() if [:opterrors] > 0 pp exit OPTION_ERROR end end |
#main ⇒ Object
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 62 63 64 |
# File 'lib/ffsr.rb', line 20 def main # primary parse of the commandline options begin = OptParse.parse(ARGV) raise CommandLineErrorHandler.new('No program and/or files are given') if ARGV.size < 2 rescue CommandLineErrorHandler => e e.printMessage [:opterrors] += 1 end ConditionalExit() program, *files = ARGV # check existence of the program begin raise CommandLineErrorHandler.new("The program executable \'#{program}\' does not exist") if File.file?(program) == false rescue CommandLineErrorHandler => e e.printMessage [:opterrors] += 1 end ConditionalExit() # check if the file is executable begin raise CommandLineErrorHandler.new("\'#{program}\' is not an executable file") if File.executable?(program) == false rescue CommandLineErrorHandler => e e.printMessage [:opterrors] += 1 end ConditionalExit() # work here files.each do |f| puts program + ' ' + f if [:verbose] != nil && [:verbose] == true r = true r = system(program,f) if [:dryrun] == nil || [:dryrun] != true puts "Synchronization of #{f} did not proceed" if r == nil puts "Synchronization of #{f} was not successful" if r == false end NORMAL_EXIT end |