Sha256: 81e4e775cfa8ab02e6c920ec90d8559a68e2e7e0a4aaf7cb3ff431715b3cce5d

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

#!/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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kmkr-0.0.2 bin/kmkr
kmkr-0.0.1 bin/kmkr