Sha256: cfdc42a523ad592b4702c133f3227442ae5d9bc2b6f7eceaf6b024d0e5e52756

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true

module TooDoo
  module Commands
    # mark task as done
    # usage: td done <task>
    class Done < Base
      def description
        <<~END
          mark task as done
          usage: td done <task>
        END
      end

      def perform!
        return puts(description) if args.empty?

        result = store.find(args.join(' '))
        unless result.nil?
          result.done!
          store.save(result)
        end

        puts build_message(result)
      end

      private

      def build_message(task)
        return 'there is no such task' if task.nil?
        "done - #{task.body}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toodoo-0.1.1 lib/toodoo/commands/done.rb