Sha256: 1a5a479e4e3efbfb0767cdf0fb0593ff3de7e18312df7ee9ebb445611f086972

Contents?: true

Size: 1.92 KB

Versions: 32

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

# @@again @@resume
desc 'Repeat last entry as new entry'
long_desc 'This command is designed to allow multiple time intervals to be created
           for an entry by duplicating it with a new start (and end, eventually) time'
command %i[again resume] do |c|
  c.example 'doing resume',
            desc: 'Duplicate the most recent entry with a new start time, removing any @done tag'
  c.example 'doing again',
            desc: 'again is an alias for resume'
  c.example 'doing resume --editor',
            desc: 'Repeat the last entry, opening the new entry in the default editor'
  c.example 'doing resume --tag project1 --in Projects',
            desc: 'Repeat the last entry tagged @project1, creating the new entry in the Projects section'
  c.example 'doing resume --interactive', desc: 'Select the entry to repeat from a menu'

  c.desc 'Get last entry from a specific section'
  c.arg_name 'NAME'
  c.flag %i[s section], default_value: 'All'

  c.desc 'Add new entry to section (default: same section as repeated entry)'
  c.arg_name 'SECTION_NAME'
  c.flag [:in]

  c.desc 'Select item to resume from a menu of matching entries'
  c.switch %i[i interactive], negatable: false, default_value: false

  add_options(:add_entry, c)
  add_options(:search, c)
  add_options(:tag_filter, c)

  c.action do |_global_options, options, _args|
    options[:fuzzy] = false

    options[:search] = options[:search].sub(/^'?/, "'") if options[:search] && options[:exact]

    if options[:back]
      options[:date] = options[:back]
      raise InvalidTimeExpression, 'Unable to parse date string for --back' if options[:date].nil?

    else
      options[:date] = Time.now
    end

    note = Doing::Note.new(options[:note])
    note.add(Doing::Prompt.read_lines(prompt: 'Add a note')) if options[:ask]

    options[:note] = note
    options[:tag] ||= []
    options[:tag_bool] = options[:bool]

    @wwid.repeat_last(options)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
doing-2.1.80 bin/commands/again.rb
doing-2.1.79 bin/commands/again.rb
doing-2.1.78 bin/commands/again.rb
doing-2.1.77 bin/commands/again.rb
doing-2.1.76 bin/commands/again.rb
doing-2.1.75 bin/commands/again.rb
doing-2.1.74 bin/commands/again.rb
doing-2.1.73 bin/commands/again.rb
doing-2.1.72 bin/commands/again.rb
doing-2.1.69 bin/commands/again.rb
doing-2.1.68 bin/commands/again.rb
doing-2.1.66 bin/commands/again.rb
doing-2.1.65 bin/commands/again.rb
doing-2.1.64 bin/commands/again.rb
doing-2.1.63 bin/commands/again.rb
doing-2.1.62 bin/commands/again.rb
doing-2.1.61 bin/commands/again.rb
doing-2.1.60 bin/commands/again.rb
doing-2.1.58 bin/commands/again.rb
doing-2.1.57 bin/commands/again.rb