Created
March 4, 2023 10:02
-
-
Save davidteren/cd36c7c878f1c6060607db5ed63de960 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'optparse' | |
def generate_links | |
# insert code to generate download links here | |
puts "Download links generated." | |
end | |
def download_packages(mandatory_only) | |
# insert code to download packages here | |
puts "Packages downloaded." | |
end | |
def install_packages(mandatory_only) | |
# insert code to install packages here | |
puts "Packages installed." | |
end | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: lpx_links.rb [options]" | |
opts.on("-g", "--generate-links", "Generate download links for Logic Pro X packages") do | |
options[:generate] = true | |
end | |
opts.on("-d", "--download", "Download Logic Pro X packages") do | |
options[:download] = true | |
end | |
opts.on("-i", "--install", "Install Logic Pro X packages") do | |
options[:install] = true | |
end | |
opts.on("-m", "--mandatory-only", "Only download/install mandatory packages") do | |
options[:mandatory] = true | |
end | |
opts.on("-h", "--help", "Prints this help") do | |
puts opts | |
exit | |
end | |
end.parse! | |
if options[:generate] | |
generate_links | |
end | |
if options[:download] | |
download_packages(options[:mandatory]) | |
end | |
if options[:install] | |
install_packages(options[:mandatory]) | |
end | |
if !options[:generate] && !options[:download] && !options[:install] | |
loop do | |
puts "Select an option:" | |
puts "1. Generate download links" | |
puts "2. Download packages" | |
puts "3. Install packages" | |
puts "4. Quit" | |
choice = gets.chomp.to_i | |
case choice | |
when 1 | |
generate_links | |
when 2 | |
puts "Download mandatory packages only? (y/n)" | |
mandatory_only = gets.chomp.downcase == 'y' | |
download_packages(mandatory_only) | |
when 3 | |
puts "Install mandatory packages only? (y/n)" | |
mandatory_only = gets.chomp.downcase == 'y' | |
install_packages(mandatory_only) | |
when 4 | |
puts "Quitting..." | |
break | |
else | |
puts "Invalid choice. Please enter a number between 1 and 4." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment