Sha256: 91779c02b759dc0e1a411d3e5fd8e15a9034c353663f4ffadd8a4931ae81b915

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 KB

Contents

module Rbnotes::Commands

  # Deletes a given note in the repository.  The timestamp string must
  # be a fully qualified one, like "20201016165130".  If no argument
  # was passed, it would try to read from the standard input.
  #
  # It does nothing to change the repository when the specified note
  # does not exist.

  class Delete < Command
    def description             # :nodoc:
      "Delete a note"
    end

    def execute(args, conf)
      stamp = Rbnotes.utils.read_timestamp(args)

      repo = Textrepo.init(conf)
      begin
        repo.delete(stamp)
      rescue Textrepo::MissingTimestampError => e
        puts e.message
      rescue StandardError => e
        puts e.message
      else
        puts "Delete [%s]" % stamp.to_s
      end
    end

    def help                    # :nodoc:
      puts <<HELP
usage:
    #{Rbnotes::NAME} delete [TIMESTAMP]

Delete a given note.  TIMESTAMP must be a fully qualified one, such
"20201016165130" or "20201016165130_012" if it has a suffix.

Delete reads its argument from the standard input when no argument was
passed in the command line.
HELP
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rbnotes-0.4.21 lib/rbnotes/commands/delete.rb
rbnotes-0.4.20 lib/rbnotes/commands/delete.rb
rbnotes-0.4.19 lib/rbnotes/commands/delete.rb
rbnotes-0.4.18 lib/rbnotes/commands/delete.rb
rbnotes-0.4.17 lib/rbnotes/commands/delete.rb
rbnotes-0.4.16 lib/rbnotes/commands/delete.rb
rbnotes-0.4.15 lib/rbnotes/commands/delete.rb
rbnotes-0.4.14 lib/rbnotes/commands/delete.rb
rbnotes-0.4.13 lib/rbnotes/commands/delete.rb
rbnotes-0.4.12 lib/rbnotes/commands/delete.rb
rbnotes-0.4.11 lib/rbnotes/commands/delete.rb
rbnotes-0.4.10 lib/rbnotes/commands/delete.rb
rbnotes-0.4.9 lib/rbnotes/commands/delete.rb
rbnotes-0.4.8 lib/rbnotes/commands/delete.rb
rbnotes-0.4.7 lib/rbnotes/commands/delete.rb
rbnotes-0.4.6 lib/rbnotes/commands/delete.rb