muse-dl/src/parser.cr

27 lines
617 B
Crystal
Raw Normal View History

2020-03-28 19:29:47 +00:00
module Muse::Dl
class Parser
@bookmarks : Bool
@tmp : String
@cleanup : Bool
@output : String
getter :bookmarks, :tmp, :cleanup, :output
def find_next(arg : Array(String), flag : String, default)
search = arg.index flag
if search
return arg[search + 1]
end
return default
end
def initialize(arg : Array(String) = [] of String)
@bookmarks = !arg.index "--no-bookmarks"
@cleanup = !arg.index "--no-cleanup"
@tmp = find_next(arg, "--tmp-dir", "/tmp")
@output = find_next(arg, "--output", "tempfilename.pdf")
end
end
end