Class: KBSecret::CLI::Command::Commands

Inherits:
Abstract
  • Object
show all
Defined in:
lib/kbsecret/cli/command/commands.rb

Overview

The implementation of kbsecret commands.

Instance Attribute Summary

Attributes inherited from Abstract

#cli

Instance Method Summary collapse

Methods inherited from Abstract

command_name, config, #setup!, #validate!

Constructor Details

#initialize(argv) ⇒ Commands

Returns a new instance of Commands.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kbsecret/cli/command/commands.rb', line 8

def initialize(argv)
  super(argv) do |cli|
    cli.slop do |o|
      o.banner = <<~HELP
        Usage:
          kbsecret commands [options]
      HELP

      o.bool "-e", "--external-only", "list only external commands"
      o.bool "-i", "--internal-only", "list only internal commands"
    end
  end
end

Instance Method Details

#run!Object

See Also:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/kbsecret/cli/command/commands.rb', line 23

def run!
  cmds = if cli.opts.external_only?
           Command.external_command_names
         elsif cli.opts.internal_only?
           Command.internal_command_names
         else
           Command.all_command_names
         end.join "\n"

  puts cmds unless cmds.empty?
end