class KBSecret::CLI::Command::RawEdit

The implementation of `kbsecret raw-edit`.

Public Class Methods

new(argv) click to toggle source
Calls superclass method KBSecret::CLI::Command::Abstract::new
# File lib/kbsecret/cli/command/raw_edit.rb, line 8
        def initialize(argv)
          super(argv) do |cli|
            cli.slop do |o|
              o.banner = <<~HELP
                Usage:
                  kbsecret raw-edit [options] <record>
              HELP

              o.string "-s", "--session", "the session to search in", default: :default
            end

            cli.dreck do
              string :label
            end

            cli.ensure_session!
          end
        end

Public Instance Methods

run!() click to toggle source

@see Command::Abstract#run!

# File lib/kbsecret/cli/command/raw_edit.rb, line 39
def run!
  Process.spawn("#{ENV["EDITOR"]} #{@record.path}")
  @record.sync! # just to bump the timestamp
end
setup!() click to toggle source

@see Command::Abstract#setup!

# File lib/kbsecret/cli/command/raw_edit.rb, line 28
def setup!
  @record = cli.session[cli.args[:label]]
end
validate!() click to toggle source

@see Command::Abstract#validate!

# File lib/kbsecret/cli/command/raw_edit.rb, line 33
def validate!
  cli.die "Missing $EDITOR." unless ENV["EDITOR"]
  cli.die "No such record." unless @record
end