module Syncthing::Helper::CLI::InstanceMethods
Public Instance Methods
col()
click to toggle source
# File lib/syncthing/helper/cli/abstract_command.rb, line 26 def col self.class.name.split('::').last.underscore.split('_').first.pluralize end
delete_record()
click to toggle source
# File lib/syncthing/helper/cli/abstract_command.rb, line 19 def delete_record idents.each do |ident| @ident = ident query ? API::Firestore.doc(col + '/' + query.first.document_id).delete : puts('record not found') end end
query()
click to toggle source
# File lib/syncthing/helper/cli/abstract_command.rb, line 13 def query API::DB_FIELDS[col].map do |f| API::Firestore.col(col).where(f, :eq, @ident) end.map(&:get).find(&:first) end
tabled_stdout(header: nil, rows: nil)
click to toggle source
DB_FIELDS = {'devices' => [:device_id, :label],
'folders' => [:id, :path, :label]}
# File lib/syncthing/helper/cli/abstract_command.rb, line 8 def tabled_stdout header: nil, rows: nil puts (TTY::Table.new header: header, rows: rows). render(:unicode, alignment: [:center], multiline: true) end
trigger_updates()
click to toggle source
# File lib/syncthing/helper/cli/abstract_command.rb, line 30 def trigger_updates API::Firestore.col('folders').get.map(&:document_id).each do |d| API::Firestore.col('folders').doc(d).update(devices: []) end Logger.tagged('trigger') {Logger.debug 'Update firestore folders'} end