quran-json/bin/quran-pull
0x1eef 2d9a22ea8f The great rewrite
The project's directory structure has been changed to be similar
to how FreeBSD organizes its filesystem. The english, portuguese,
and farsi translations are now sourced from https://quran.com. The
original Arabic is still sourced from searchtruth.com. Files
have been removed, and / or replaced. The SQL-related files have
been removed, with the intention to separate them into a new project
in the future (quran-sql). The lessons learnt from the development of
quran-audio were an inspiration for this change.
2023-02-08 16:14:48 -03:00

35 lines
770 B
Ruby

#!/usr/bin/env ruby
##
# Utils
def spawn(libexec_dir, exec, *args)
Process.spawn File.join(libexec_dir, exec), *args
end
def wait(pid)
Process.wait(pid)
rescue Interrupt
retry
end
##
# main
def main(argv)
root_dir = File.realpath(File.join(__dir__, ".."))
lib_dir = File.join(root_dir, "lib", "quran-pull")
libexec_dir = File.join(root_dir, "libexec", "quran-pull")
require File.join(lib_dir, "pull")
case ARGV[0]
when "pull"
options = Pull.cli(argv[1..])
if %w[en pt fa].include?(options.locale)
wait spawn(libexec_dir, "quran.com", *argv[1..])
elsif %w[ar].include?(options.locale)
wait spawn(libexec_dir, "searchtruth.com", *argv[1..])
end
else
warn "Usage: quran-pull pull|help [OPTIONS]"
end
end
main(ARGV)