Skip to content

Commit

Permalink
add year parameter to specify movie by year
Browse files Browse the repository at this point in the history
  • Loading branch information
koffeinfrei committed Sep 9, 2019
1 parent eac312a commit c3de45f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/lookup.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ class Lookup
property error : String | Nil
property result_output : ResultOutput

def initialize(title, show_links = false)
def initialize(title, show_links = false, year = nil)
@movie = Movie.new(title)
@movie.year = year if year

@channels = {
progress: Channel(Nil).new,
Expand Down Expand Up @@ -110,6 +111,7 @@ class Lookup
"OMDb API key is not valid.",
}).run(->abort(String), {
:t => movie.title,
:y => movie.year,
:tomatoes => "true",
:apikey => omdb_api_key,
})
Expand Down
5 changes: 4 additions & 1 deletion src/should-i-watch-this.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class ShouldIWatchThis < Cli::Supercommand
arg "title",
required: true,
desc: "The title of the movie"
string ["-y", "--year"],
required: false,
desc: "The relase year of the movie"
bool ["-l", "--show-links"],
default: false,
desc: "Output links to movies on the different platforms"
Expand All @@ -44,7 +47,7 @@ class ShouldIWatchThis < Cli::Supercommand
# to the title argument
title = ([args.title] + args.nameless_args).join(" ")

::Lookup.new(title, show_links: args.show_links?).run
::Lookup.new(title, show_links: args.show_links?, year: args.year?).run
end
end

Expand Down

0 comments on commit c3de45f

Please sign in to comment.