bin/srd in sifttter-redux-0.2.5 vs bin/srd in sifttter-redux-0.3.0

- old
+ new

@@ -90,58 +90,80 @@ desc 'Execute the script' command :exec do |c| c.flag( - [:f, :from], + [:f], :desc => 'Run catch-up mode with this start date', ) c.flag( - [:t, :to], - :desc => 'Run catch-up mode with this end date (must be accompanied by --from)', + [:n], + :desc => 'Run catch-up mode for the last N days' ) + + c.flag( + [:t], + :desc => 'Run catch-up mode with this end date (must be accompanied by -f)', + ) + c.flag( + [:w], + :desc => 'Run catch-up mode for the last N weeks' + ) + c.switch( - [:c, :last_7_days], - :desc => 'Run catch-up mode for the last 7 days' + [:c], + :desc => 'Run catch-up mode for the current week (i.e., the beginning of the week to yesterday)' ) c.switch( - [:i, :include_today], + [:i], :desc => 'Include today\'s date in catch-up' ) c.switch( - [:y, :yesterday], + [:y], :desc => 'Run catch-up mode for yesterday' ) c.action do |global_options, options, args| command_complete = false - + CliMessage.section('EXECUTING...') + + if (options[:c] || options[:n] || options[:w] || options[:y] || options[:f] || options[:t]) - if (options[:c] || options[:y] || options[:f] || options[:t]) + # Current Week if (!command_complete && options[:c]) - dates = $date_range_maker.last_seven_days(options[:i]) + dates = $date_range_maker.last_n_weeks(0, {:include_today => options[:i]}) command_complete = true end + # Last N Days + if (!command_complete && options[:n]) + dates = $date_range_maker.last_n_days(options[:n].to_i, {:include_today => options[:i]}) + command_complete = true + end + + # Yesterday if (!command_complete && options[:y]) dates = $date_range_maker.yesterday command_complete = true end + # Last N Weeks + if (!command_complete && options[:w]) + dates = $date_range_maker.last_n_weeks(options[:w].to_i, {:include_today => options[:i]}) + command_complete = true + end + + # Specific Range if (!command_complete && (options[:f] || options[:t])) begin - dates = $date_range_maker.range({ - :start_date => options[:f], - :end_date => options[:t], - :include_today => options[:i], - }) - + dates = $date_range_maker.range(options[:f], options[:t], {:include_today => options[:i]}) + if (dates.last > Date.today) CliMessage.warning("Ignoring overextended end date and using today's date (#{Date.today})") dates = (dates.first..Date.today) end rescue DateRangeMakerError @@ -153,16 +175,24 @@ dates = $date_range_maker.today command_complete = true end if (!dates.nil?) - CliMessage.info("Creating entries for dates from #{dates.first} to #{dates.reverse_each.first}...") + first_date = dates.first + second_date = dates.reverse_each.first + + if (first_date == second_date) + CliMessage.info("Creating entry for #{first_date.strftime('%B %d, %Y')}...") + else + CliMessage.info("Creating entries for dates from #{first_date.strftime('%B %d, %Y')} to #{second_date.strftime('%B %d, %Y')}...") + end download_sifttter_files dates.each do |date| run_sifttter(date) end + # Upload any Day One entries to Dropbox (if there are any). if (!Dir[$config.sifttter_redux["dayone_local_filepath"] + "/*"].empty?) CliMessage.info("Uploading Day One entries to Dropbox...", false) output = `#{$db_uploader} upload #{$config.sifttter_redux["dayone_local_filepath"] + "/*"} #{$config.sifttter_redux["dayone_remote_filepath"]}` CliMessage.finish_message('DONE.')