class KBSecret::CLI::Command::Abstract
Represents an abstract {KBSecret} command that can be subclassed to produce a more useful command. {KBSecret::CLI::Command::List} is an example of this. @abstract
Attributes
cli[R]
@return [CLI] the CLI
state corresponding to the command
Public Class Methods
command_name()
click to toggle source
@return [String] the command's CLI-friendly name @example
KBSecret::CLI::Command::StashFile # => "stash-file"
# File lib/kbsecret/cli/command/abstract.rb, line 16 def self.command_name name.split("::") .last .gsub(/([^A-Z])([A-Z]+)/, '\1-\2') .downcase end
config()
click to toggle source
@return [Hash, nil] the configuration for the command, if any.
# File lib/kbsecret/cli/command/abstract.rb, line 32 def self.config KBSecret::Config.command(command_name) end
new(argv) { |cli| ... }
click to toggle source
@param argv [String] the arguments to call the command with
# File lib/kbsecret/cli/command/abstract.rb, line 24 def initialize(argv) @cli = CLI.create(argv) { |_o| nil } @cli.guard do yield @cli if block_given? end end
Public Instance Methods
run!()
click to toggle source
Runs the command. Implemented by children. @abstract
# File lib/kbsecret/cli/command/abstract.rb, line 50 def run! nil end
setup!()
click to toggle source
Sets up any state used by the command. Implemented by children. @abstract
# File lib/kbsecret/cli/command/abstract.rb, line 38 def setup! nil end
validate!()
click to toggle source
Runs any validation checks required by the command. Implemented by children. @abstract
# File lib/kbsecret/cli/command/abstract.rb, line 44 def validate! nil end