Class: Vaulty::CLI::Tree

Inherits:
Command show all
Defined in:
lib/vaulty/cli/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#banner, call, #prompt, #table

Constructor Details

#initialize(catacomb:) ⇒ Tree

Returns a new instance of Tree.

Parameters:



6
7
8
# File 'lib/vaulty/cli/tree.rb', line 6

def initialize(catacomb:)
  @catacomb = catacomb
end

Instance Attribute Details

#catacombObject (readonly)

Returns the value of attribute catacomb.



4
5
6
# File 'lib/vaulty/cli/tree.rb', line 4

def catacomb
  @catacomb
end

Instance Method Details

#callObject

Raises:



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vaulty/cli/tree.rb', line 10

def call
  spinner = TTY::Spinner.new('Loading :spinner', format: :arrow_pulse, clear: true)
  spinner.auto_spin
  vaulty_tree = Vaulty::VaultTree.new(catacomb: catacomb).tree
  spinner.stop

  raise Vaulty::EmptyPath, catacomb.path if vaulty_tree.empty?

  Vaulty::Output::Tree.render(vaulty_tree, prompt: prompt)
  vaulty_tree
end