Sha256: e667b294cacc8f5067eb4aead6eb10fd256f36e7e5a0b58c0ab9ebace60b70df
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
require "optparse" require "daily_weekly_monthly" module DailyWeeklyMonthly class Cli def initialize args @options = {} @command = parse args raise "Please supply a command to run" if @command.empty? @command = @command.join(" ") end def call DailyWeeklyMonthly.start @command, @options end private # rubocop : disable Metrics/MethodLength def parse args args.options do |opts| opts.banner = "Usage: daily_weekly_monthly \"database backup command\" [options]" parse_dir(opts) parse_ext(opts) parse_week_day(opts) parse_month_day(opts) parse_keep_days(opts) parse_keep_weeks(opts) parse_keep_months(opts) opts.parse! end args end def parse_keep_months opts opts.on("-M n", "--months-to-keep=n", "Monthly backups to keep", OptionParser::DecimalInteger) do |n| @options[:months_to_keep] = n end end def parse_keep_weeks opts opts.on("-W n", "--weeks-to-keep=n", "Weekly backups to keep", OptionParser::DecimalInteger) do |n| @options[:weeks_to_keep] = n end end def parse_keep_days opts opts.on("-D n", "--days-to-keep=n", "Daily backups to keep", OptionParser::DecimalInteger) do |n| @options[:days_to_keep] = n end end def parse_month_day opts opts.on("-m n", "--month-day=n", "Day of month to run on", OptionParser::DecimalInteger) do |n| @options[:day_of_month] = n end end def parse_ext opts opts.on("-e e", "--ext=e", "Backup file extension", String) do |e| @options[:output_extension] = e end end def parse_week_day opts opts.on("-w n", "--week-day=n", "Week day to run on", OptionParser::DecimalInteger) do |n| @options[:day_of_week] = n end end def parse_dir opts opts.on("-d d", "--dir=d", "Backups directory path", String) do |d| @options[:backups_dir] = d end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
daily_weekly_monthly-0.0.2 | lib/daily_weekly_monthly/cli.rb |