From a1b3b7baf8ae918211cdd81498cf60ae5d914c1a Mon Sep 17 00:00:00 2001 From: koffeejava Date: Fri, 13 Mar 2026 11:12:55 -0600 Subject: [PATCH] Updated version and finished installer. --- src/installer.cr | 68 +++++++++++++++++++++++++++++++++++++++++++++++- src/wfetch.cr | 4 +-- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/installer.cr b/src/installer.cr index 0583669..b23aaa3 100644 --- a/src/installer.cr +++ b/src/installer.cr @@ -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") diff --git a/src/wfetch.cr b/src/wfetch.cr index 17eafe8..65de2a0 100644 --- a/src/wfetch.cr +++ b/src/wfetch.cr @@ -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