Class: KBSecret::CLI::Command::Conf
- Defined in:
- lib/kbsecret/cli/command/conf.rb
Overview
The implementation of kbsecret conf
.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(argv) ⇒ Conf
constructor
A new instance of Conf.
- #run! ⇒ Object
- #validate! ⇒ Object
Methods inherited from Abstract
Constructor Details
#initialize(argv) ⇒ Conf
Returns a new instance of Conf.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kbsecret/cli/command/conf.rb', line 8 def initialize(argv) super(argv) do |cli| cli.slop do |o| o. = <<~HELP Usage: kbsecret conf [options] HELP o.bool "-c", "--commands", "open the commands config (commands.ini)" o.bool "-d", "--directory", "print the path to the config directory" o.bool "-r", "--record-directory", "print the path to the custom record directory" end end end |
Instance Method Details
#run! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kbsecret/cli/command/conf.rb', line 28 def run! if cli.opts.commands? exec "#{ENV["EDITOR"]} #{Config::COMMAND_CONFIG_FILE}" elsif cli.opts.directory? puts Config::CONFIG_DIR elsif cli.opts.record_directory? puts Config::CUSTOM_TYPES_DIR else exec "#{ENV["EDITOR"]} #{Config::CONFIG_FILE}" end end |
#validate! ⇒ Object
23 24 25 |
# File 'lib/kbsecret/cli/command/conf.rb', line 23 def validate! cli.die "Missing $EDITOR." unless ENV["EDITOR"] end |