Class: Cli::LibrariesCommand

Inherits:
Thor
  • Object
show all
Defined in:
app/lib/cli/libraries_command.rb

Constant Summary collapse

DESCRIPTION =
"manage libraries"

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/lib/cli/libraries_command.rb', line 20

def create
  l = Library.create(name: options[:name], path: options[:path], storage_service: "filesystem")
  if l.valid?
    puts "\nNew library created OK"
  else
    puts "\nError when creating library:\n"
    puts l.errors.full_messages.inspect
  end
end

#scan ⇒ Object



10
11
12
13
14
15
# File 'app/lib/cli/libraries_command.rb', line 10

def scan
  scope = Library.all # rubocop:disable Pundit/UsePolicyScope
  scope = scope.where(name: options[:name]) if options[:name].presence
  puts "\nQueueing #{scope.count} #{"library".pluralize(scope.count)} for filesystem scan"
  scope.find_each(&:detect_filesystem_changes_later)
end