bin/crack
#!/usr/bin/env ruby
require 'enygma'
if ARGV[0] && (ARGV[0] == 'help' || ARGV[0] == '--help' || ARGV[0] == '-h')
Enygma::Help.crack
elsif ARGV.length < 2 || ARGV.length > 3
puts "Incorrect number of argument. Run with --help for explanation"
elsif !File.file?(ARGV[0])
puts "The input file path does not exist. Run with --help for explanation"
elsif ARGV.length == 3 && File.file?(ARGV[1])
puts "The output file path cannot be created, or file already exist. Run with --help for explanation"
else
if ARGV.length == 3
Enygma::Cracker.new(ARGV[0], ARGV[1], ARGV[2]).crack
else
Enygma::Cracker.new(ARGV[0], ARGV[1]).crack
end
end