Class: SidekiqUniqueJobs::Cli

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)

@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel

end


11
12
13
# File 'lib/sidekiq_unique_jobs/cli.rb', line 11

def self.banner(command, _namespace = nil, _subcommand = false)
  "jobs #{@package_name} #{command.usage}"
end

Instance Method Details

#consoleObject


39
40
41
42
43
44
45
# File 'lib/sidekiq_unique_jobs/cli.rb', line 39

def console
  say "Use `keys '*', 1000 to display the first 1000 unique keys matching '*'"
  say "Use `del '*', 1000, true (default) to see how many keys would be deleted for the pattern '*'"
  say "Use `del '*', 1000, false to delete the first 1000 keys matching '*'"
  Object.include SidekiqUniqueJobs::Util
  console_class.start
end

#del(pattern) ⇒ Object


26
27
28
29
# File 'lib/sidekiq_unique_jobs/cli.rb', line 26

def del(pattern)
  deleted_count = Util.del(pattern, options[:count], options[:dry_run])
  say "Deleted #{deleted_count} keys matching '#{pattern}'"
end

#expireObject


32
33
34
35
36
# File 'lib/sidekiq_unique_jobs/cli.rb', line 32

def expire
  expired = Util.expire
  say "Removed #{expired.values.size} left overs from redis."
  print_in_columns(expired.values)
end

#keys(pattern) ⇒ Object


17
18
19
20
21
# File 'lib/sidekiq_unique_jobs/cli.rb', line 17

def keys(pattern)
  keys = Util.keys(pattern, options[:count])
  say "Found #{keys.size} keys matching '#{pattern}':"
  print_in_columns(keys.sort) if keys.any?
end