#!/usr/bin/env ruby require 'optparse' require 'methadone' require 'kmkr.rb' require 'pry' class App include Methadone::Main include Methadone::CLILogging main do |extension| prefix = Kmkr::PrefixDate.new(options[:f]).to_s Kmkr::FileManager.new(prefix, extension, options[:directory], options[:suffix]).create_file debug("directory: #{options[:directory]}") debug("date format: #{options[:f]}") debug("prefix: #{prefix}") debug("suffix: #{options[:suffix]}") end # supplemental methods here # Declare command-line interface here description 'Creates files with names prefixed by date' # Accept flags via: # on("--flag VAL","Some flag") # options[flag] will contain VAL # # Specify switches via: # on("--[no-]switch","Some switch") # # Or, just call OptionParser methods on opts # options[:directory] = Dir.pwd options[:f] = '%d-%m-%Y' options[:suffix] = "" on('-d DIR', '--directory', 'Set the location where the file should be saved') on('-f DATEFORMAT', '--date-format', 'Use a different date format for the filename prefixes') on('-s SUFFIX', '--suffix', 'Add a suffix to the filename') arg :extension, 'Extension of the file to create' # # Make an argument optional # arg :optional_arg, :optional version Kmkr::VERSION use_log_level_option :toggle_debug_on_signal => 'USR1' go! end