Class: Vaulty::CLI::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vaulty/cli/command.rb

Direct Known Subclasses

Add, Delete, Remove, Tree

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args) ⇒ Object

Initializes a new command with the args and calls it

Parameters:

  • args (Hash)

    anything



33
34
35
# File 'lib/vaulty/cli/command.rb', line 33

def self.call(*args)
  new(*args).call
end

Instance Method Details

Render a banner

Parameters:

  • msg (String)

    to be placed in the banner

  • color (Symbol) (defaults to: :green)

    optional color

See Also:



16
17
18
# File 'lib/vaulty/cli/command.rb', line 16

def banner(msg, color: :green)
  Vaulty::Output::Banner.render(msg, color: color, prompt: prompt)
end

#callObject

Interface method should be defined by subclasses

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/vaulty/cli/command.rb', line 7

def call
  raise NotImplementedError, "#{inspect}.call is not implemented"
end

#promptTTY::Prompt

Returns an instance of TTY::Prompt

Returns:

  • (TTY::Prompt)

    instance



40
41
42
# File 'lib/vaulty/cli/command.rb', line 40

def prompt
  Vaulty.prompt
end

#table(data, highlight: {}) ⇒ Object

Renders a table

Parameters:

  • data (Array<Array>)

    row/columns

  • highlgiht (Hash)

    options passed to (see Vaulty::Output::HighlightFilter)

  • highlight (Hash) (defaults to: {})

    a customizable set of options

Options Hash (highlight:):

  • :matching (Array)

    strings to highlight

  • :color (Symbol)

    to be used for highlighting



26
27
28
# File 'lib/vaulty/cli/command.rb', line 26

def table(data, highlight: {})
  Vaulty::Output::Table.render(data, highlight: highlight, prompt: prompt)
end