64 lines
1.3 KiB
Crystal
64 lines
1.3 KiB
Crystal
|
|
require "option_parser"
|
|
|
|
require "./duration"
|
|
require "./meta_data"
|
|
require "./controllers/info_controller"
|
|
require "./controllers/download_controller"
|
|
|
|
# Cli part of FosdemRecorder
|
|
module FosdemRecorder
|
|
# Fosdem Cli - Download and cut streams video
|
|
class Cli
|
|
enum Actions
|
|
Info
|
|
None
|
|
end
|
|
|
|
property action : Actions = Actions::None
|
|
|
|
def initialize(args)
|
|
if args
|
|
parse args
|
|
end
|
|
end
|
|
|
|
def self.start(args)
|
|
Cli.new(args)
|
|
end
|
|
|
|
|
|
|
|
private def parse(args)
|
|
commands = [] of Proc(String, Nil)
|
|
|
|
OptionParser.parse(args) do |opts|
|
|
opts.banner = "Usage: fosdem-recorder [subcommand] [arguments]"
|
|
|
|
# opts.on("update-cache", "Fetch schedule information") do
|
|
# commands << ->InfoController.process(String)
|
|
# end
|
|
|
|
opts.on("info", "Get information about URL") do
|
|
commands << ->InfoController.process(String)
|
|
end
|
|
|
|
opts.on("download", "Download conference described at URL") do
|
|
commands << ->DownloadController.process(String)
|
|
end
|
|
|
|
opts.on("-h", "--help", "Shows this help") do
|
|
puts opts
|
|
exit 0
|
|
end
|
|
end
|
|
|
|
commands.each do |proc|
|
|
targs = Tuple(String).from(args)
|
|
proc.call(*targs)
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|