Updated version and finished installer.

This commit is contained in:
koffeejava
2026-03-13 11:12:55 -06:00
parent 89c2b85dbc
commit a1b3b7baf8
2 changed files with 69 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
require "option_parser"
orange = "\e[38;5;214m"
red = "\e[0;31m"
bold = "\033[1m"
@@ -15,7 +17,71 @@ end
sudo_user = ENV["SUDO_USER"]?
home = "/home/#{sudo_user}"
puts "#{orange}#{bold}wfetch installer 0.1.0#{reset}"
OptionParser.parse do |parser|
parser.banner = "Usage: installer [arguments]"
parser.on("-i", "--install-only", "Only instals wfetch; Does not run setup") {
puts "#{orange}#{bold}wfetch installer 1.0.0#{reset}"
File.copy("data/wfetch", "/usr/bin/wfetch")
puts "#{orange}#{bold}Finished installing!#{reset}"
exit
}
parser.on("-u", "--uninstall", "Uninstalls wfetch"){
File.delete("/usr/bin/wfetch")
File.delete("#{home}/.local/share/Wfetch/disp.toml")
File.delete("#{home}/.local/share/Wfetch/config.toml")
Dir.delete("#{home}/.local/share/Wfetch")
puts "#{bold}#{orange}Finished#{reset}"
exit
}
parser.on("-s", "--setup", "Runs setup") {
Dir.mkdir("/home/#{sudo_user}/.local/share/Wfetch")
puts "Please enter your WeatherApi key (Learn to get one at README.md):"
api = gets
puts "Please enter the (closest) city you live in: "
city = gets
puts "#{orange}#{bold}Config setup finished. Starting disp setup.#{reset}"
File.write("/home/#{sudo_user}/.local/share/Wfetch/config.toml", "api = \"#{api}\"
city = \"#{city}\"")
puts "#{orange}#{bold}Would you like customary (1), metric (2), or both (3)?#{reset}"
choice = gets
if choice == "1"
File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
elsif choice == "2"
File.copy("data/2.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
elsif choice == "3"
File.copy("data/3.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
else
File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
end
puts "#{orange}#{bold}Setup finnished. Enjoy!#{reset}"
exit
}
parser.on("-h", "--help", "Show this help") do
puts parser
exit(1)
end
parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser
exit(1)
end
end
puts "#{orange}#{bold}wfetch installer 1.0.0#{reset}"
File.copy("data/wfetch", "/usr/bin/wfetch")

View File

@@ -5,7 +5,7 @@ require "./icon-list"
require "option_parser"
module Wfetch
VERSION = "0.1.0"
VERSION = "1.0.0"
orange = "\e[38;5;214m"
red = "\e[0;31m"
bold = "\033[1m"
@@ -29,7 +29,7 @@ module Wfetch
}
parser.on("-r", "--verbose", "Gives additional details.") {debug = true}
parser.on("-v", "--version", "Shows the current version of wfetch") {
puts "#{bold}#{orange}Wfetch 0.1.0 KoffeeJava 2026#{reset}"
puts "#{bold}#{orange}Wfetch 1.0.0 KoffeeJava 2026#{reset}"
exit
}
parser.on("-h", "--help", "Show this help") do