Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0835b41519 |
@@ -8,8 +8,8 @@ targets:
|
||||
wfetch:
|
||||
main: src/wfetch.cr
|
||||
|
||||
wf-tool:
|
||||
main: src/wf-tool.cr
|
||||
wfp-tool:
|
||||
main: src/wfp-tool.cr
|
||||
|
||||
crystal: '>= 1.19.1'
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
require "option_parser"
|
||||
|
||||
orange = "\e[38;5;214m"
|
||||
red = "\e[0;31m"
|
||||
bold = "\033[1m"
|
||||
reset = "\e[0m"
|
||||
|
||||
sudo_user = ENV["SUDO_USER"]?
|
||||
home = "/home/#{sudo_user}"
|
||||
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "Usage: wf-tool [arguments]"
|
||||
parser.on("-i", "--install-only", "Only instals wfetch; Does not run setup") {
|
||||
if LibC.getuid != 0
|
||||
puts "#{red}#{bold}You must be in root to install wfetch!#{reset}"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
puts "#{orange}#{bold}wfetch installer#{reset}"
|
||||
|
||||
File.copy("data/wfetch", "/usr/bin/wfetch")
|
||||
|
||||
puts "#{orange}#{bold}Finished installing!#{reset}"
|
||||
exit
|
||||
}
|
||||
parser.on("-u", "--uninstall", "Uninstalls wfetch"){
|
||||
if LibC.getuid != 0
|
||||
puts "#{red}#{bold}You must be in root to uninstall wfetch!#{reset}"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
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") {
|
||||
if LibC.getuid == 0
|
||||
puts "#{red}#{bold}Don't run the setup in root!#{reset}"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
Dir.mkdir(Path["~/.local/share/Wfetch"].expand(home: true))
|
||||
|
||||
|
||||
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(Path["~/.local/share/Wfetch/config.toml"].expand(home: true), "
|
||||
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", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))
|
||||
elsif choice == "2"
|
||||
File.copy("data/2.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))
|
||||
elsif choice == "3"
|
||||
File.copy("data/3.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))
|
||||
else
|
||||
File.copy("data/1.toml", Path["~/.local/share/Wfetch/disp.toml"].expand(home: true))
|
||||
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
|
||||
|
||||
if ARGV.empty?
|
||||
puts "Run wf-tool -h"
|
||||
end
|
||||
@@ -1,5 +1,3 @@
|
||||
# test :)
|
||||
|
||||
require "http/client"
|
||||
require "json"
|
||||
require "toml"
|
||||
@@ -36,7 +34,6 @@ module Wfetch
|
||||
}
|
||||
parser.on("-v", "--version", "Shows the current version of wfetch") {
|
||||
puts "#{bold}#{orange}Wfetch 1.1.0 KoffeeJava 2026#{reset}"
|
||||
puts "Made in Crystal by KoffeeJava with Love"
|
||||
exit
|
||||
}
|
||||
parser.on("-h", "--help", "Show this help") do
|
||||
@@ -52,7 +49,7 @@ module Wfetch
|
||||
|
||||
print "#{bold}#{orange}Wfetch KoffeeJava 2026#{reset}"
|
||||
|
||||
config = TOML.parse(File.read("config/config.toml")].expand(home: true)))
|
||||
config = TOML.parse(File.read(Path["~/.local/share/Wfetch/config.toml"].expand(home: true)))
|
||||
city = config["city"]
|
||||
api_key = config["api"]
|
||||
|
||||
@@ -107,7 +104,7 @@ module Wfetch
|
||||
path_config = gets
|
||||
disp = TOML.parse(File.read(Path["#{path_config}"].expand(home: true)))
|
||||
else
|
||||
disp = TOML.parse(File.read())
|
||||
disp = TOML.parse(File.read(Path["~/.local/share/Wfetch/disp.toml"].expand(home: true)))
|
||||
end
|
||||
|
||||
repeat = 1
|
||||
|
||||
40
src/wfp-tool.cr
Normal file
40
src/wfp-tool.cr
Normal file
@@ -0,0 +1,40 @@
|
||||
orange = "\e[38;5;214m"
|
||||
red = "\e[0;31m"
|
||||
bold = "\033[1m"
|
||||
reset = "\e[0m"
|
||||
|
||||
Dir.mkdir("config")
|
||||
|
||||
|
||||
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("config/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", "config/disp.toml")
|
||||
elsif choice == "2"
|
||||
File.copy("data/2.toml", "config/disp.toml")
|
||||
elsif choice == "3"
|
||||
File.copy("data/3.toml", "config/disp.toml")
|
||||
else
|
||||
File.copy("data/1.toml", "config/disp.toml")
|
||||
end
|
||||
|
||||
puts "#{orange}#{bold}Setup finnished. Enjoy!#{reset}"
|
||||
|
||||
Dir.remove("data")
|
||||
Reference in New Issue
Block a user