Class: Tsearch::CLI

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

Overview

Handle the application command line parsing and the dispatch to various command objects

Constant Summary collapse

Error =

Error raised by this runner

Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#searchObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tsearch/cli.rb', line 45

def search
  if options[:help]
    invoke :help, ['search']
  else
    if options[:string].nil? && options[:imdb].nil? && options[:tvdb].nil? && options[:themoviedb].nil?
      raise RequiredArgumentMissingError,
            'At least one of the search options must be provided: string, imdb, tvdb, themoviedb'
    end

    require_relative 'commands/search'
    Tsearch::Commands::Search.new(options).execute
  end
end

#versionObject



19
20
21
22
# File 'lib/tsearch/cli.rb', line 19

def version
  require_relative 'version'
  puts "v#{Tsearch::VERSION}"
end