lib/filename_cleaner/cli.rb
def sanitize_and_rename(options = {})
      files = CodeLister.files(options)
      if files.empty?
        puts "No match found for your options :#{options}"
      else
        files.each_with_index do |file, index|
          puts "FYI: process : #{index + 1} of #{files.size}"
          dirname  = File.dirname(File.expand_path(file))
          filename = File.basename(file)
          new_name = FilenameCleaner.formatted_name(filename, options)
          old_name = File.expand_path(file)
          new_name = File.expand_path([dirname, new_name].join(File::SEPARATOR))
          compare_and_rename(old_name, new_name, options[:commit])
        end
        unless options[:commit]
          puts "--------------------------------------------------------------"
          puts "This is a dry run, to commit your change, please use --commit option"
          puts "--------------------------------------------------------------"
        end
      end
    end
def sanitize_and_rename(options = {})
      files = CodeLister.files(options)
      if files.empty?
        puts "No match found for your options :#{options}"
      else
        files.each_with_index do |file, index|
          puts "FYI: process : #{index + 1} of #{files.size}"
          dirname  = File.dirname(File.expand_path(file))
          filename = File.basename(file)
          new_name = FilenameCleaner.formatted_name(filename, options)
          old_name = File.expand_path(file)
          new_name = File.expand_path([dirname, new_name].join(File::SEPARATOR))
          compare_and_rename(old_name, new_name, options[:commit])
        end
        unless options[:commit]
          puts "--------------------------------------------------------------"
          puts "This is a dry run, to commit your change, please use --commit option"
          puts "--------------------------------------------------------------"
        end
      end
    end
rubocop:disable LineLength