fosdem-recorder.cr/src/cli.cr

64 lines
1.3 KiB
Crystal
Raw Normal View History

2022-02-05 20:15:53 +00:00
require "option_parser"
2023-02-05 15:36:09 +00:00
require "./duration"
require "./meta_data"
require "./controllers/info_controller"
require "./controllers/download_controller"
2022-02-05 20:15:53 +00:00
# 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]"
2023-02-05 15:36:09 +00:00
# opts.on("update-cache", "Fetch schedule information") do
# commands << ->InfoController.process(String)
# end
2022-02-05 20:15:53 +00:00
opts.on("info", "Get information about URL") do
2023-02-05 15:36:09 +00:00
commands << ->InfoController.process(String)
2022-02-05 20:15:53 +00:00
end
opts.on("download", "Download conference described at URL") do
2023-02-05 15:36:09 +00:00
commands << ->DownloadController.process(String)
2022-02-05 20:15:53 +00:00
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