Class: SidekiqUniqueJobs::Cli

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

Overview

Command line interface for unique jobs

Author:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

:nodoc: rubocop:disable Style/OptionalBooleanParameter



14
15
16
# File 'lib/sidekiq_unique_jobs/cli.rb', line 14

def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
  "jobs #{@package_name} #{command.usage}" # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
end

Instance Method Details

#consoleObject

:nodoc:



45
46
47
48
49
50
51
52
# File 'lib/sidekiq_unique_jobs/cli.rb', line 45

def console
  say "Use `list '*', 1000 to display the first 1000 unique digests matching '*'"
  say "Use `del '*', 1000, true (default) to see how many digests would be deleted for the pattern '*'"
  say "Use `del '*', 1000, false to delete the first 1000 digests matching '*'"

  # Object.include SidekiqUniqueJobs::Api
  console_class.start
end

#del(pattern) ⇒ Object

:nodoc:



34
35
36
37
38
39
40
41
# File 'lib/sidekiq_unique_jobs/cli.rb', line 34

def del(pattern)
  max_count = options[:count]
  if options[:dry_run]
    count_entries_for_del(max_count, pattern)
  else
    del_entries(max_count, pattern)
  end
end

#list(pattern = "*") ⇒ Object

:nodoc:



22
23
24
25
26
27
28
# File 'lib/sidekiq_unique_jobs/cli.rb', line 22

def list(pattern = "*")
  max_count = options[:count]
  say "Searching for regular digests"
  list_entries(digests.entries(pattern: pattern, count: max_count), pattern)
  say "Searching for expiring digests"
  list_entries(expiring_digests.entries(pattern: pattern, count: max_count), pattern)
end