Class: KBSecret::CLI::Command::RawEdit
- Defined in:
- lib/kbsecret/cli/command/raw_edit.rb
Overview
The implementation of kbsecret raw-edit
.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(argv) ⇒ RawEdit
constructor
A new instance of RawEdit.
- #run! ⇒ Object
- #setup! ⇒ Object
- #validate! ⇒ Object
Methods inherited from Abstract
Constructor Details
#initialize(argv) ⇒ RawEdit
Returns a new instance of RawEdit.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kbsecret/cli/command/raw_edit.rb', line 8 def initialize(argv) super(argv) do |cli| cli.slop do |o| o. = " Usage:\n kbsecret raw-edit [options] <record>\n HELP\n\n o.string \"-s\", \"--session\", \"the session to search in\", default: :default\n end\n\n cli.dreck do\n string :label\n end\n\n cli.ensure_session!\n end\nend\n" |
Instance Method Details
#run! ⇒ Object
39 40 41 42 |
# 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! ⇒ Object
28 29 30 |
# File 'lib/kbsecret/cli/command/raw_edit.rb', line 28 def setup! @record = cli.session[cli.args[:label]] end |
#validate! ⇒ Object
33 34 35 36 |
# 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 |