commit ac429a8fc3d764103fb9f619e71f855efa7e085d Author: koffeejava Date: Thu Mar 12 18:41:15 2026 -0600 Inital commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..163eb75 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.cr] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bb75ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/docs/ +/lib/ +/bin/ +/.shards/ +*.dwarf diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..31593d8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 koffeejava + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1205d33 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# wfetch + +TODO: Write a description here + +## Installation + +TODO: Write installation instructions here + +## Usage + +TODO: Write usage instructions here + +## Development + +TODO: Write development instructions here + +## Contributing + +1. Fork it () +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request + +## Contributors + +- [koffeejava](https://github.com/your-github-user) - creator and maintainer diff --git a/shard.lock b/shard.lock new file mode 100644 index 0000000..58530bb --- /dev/null +++ b/shard.lock @@ -0,0 +1,6 @@ +version: 2.0 +shards: + toml: + git: https://github.com/crystal-community/toml.cr.git + version: 0.8.1+git.commit.030a3866af395bfb9fe2cce234d9b3d0d8f3ad3c + diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..c4e0d40 --- /dev/null +++ b/shard.yml @@ -0,0 +1,18 @@ +name: wfetch +version: 0.1.0 + +authors: + - koffeejava + +targets: + wfetch: + main: src/wfetch.cr + +crystal: '>= 1.19.1' + +license: MIT + +dependencies: + toml: + github: crystal-community/toml.cr + branch: master \ No newline at end of file diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..935d4f2 --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/wfetch" diff --git a/spec/wfetch_spec.cr b/spec/wfetch_spec.cr new file mode 100644 index 0000000..36181cd --- /dev/null +++ b/spec/wfetch_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe Wfetch do + # TODO: Write tests + + it "works" do + false.should eq(true) + end +end diff --git a/src/icon-list.cr b/src/icon-list.cr new file mode 100644 index 0000000..e6acfad --- /dev/null +++ b/src/icon-list.cr @@ -0,0 +1,78 @@ + + +def icon(id) + orange = "\e[38;5;214m" + gray = "\e[38;5;241m" + blue = "\e[38;5;33m" + yellow = "\e[38;5;220m" + reset = "\e[0m" + bold = "\033[1m" + if id == 1000 + print "#{bold}#{orange} + ⠀⠀⠀⠀⡄⡢⡪⢪⢊⠎⡆⡢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⡑⡅⡇⢎⢪⢸⢘⢌⢎⢜⢔⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⡰⡡⡣⡱⡸⡘⡌⡆⢇⢕⠜⡔⡱⢱⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⡪⡢⡱⡸⡐⡕⡱⡸⡘⡔⢕⢱⢸⢨⠂⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⢊⢆⢣⢪⠸⡨⡢⢣⠪⡊⡎⡪⢢⠣⠁⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠣⡱⡸⡘⡌⢎⠆⡇⡣⡪⡊⡆⠃⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠌⡪⡸⡨⡪⢪⠸⡐⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⠀⠀#{reset}" + elsif id == 1003 + print "#{bold}#{orange} ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{bold}#{orange}⠀⠀⢠⢠⢢⢢⢢⢢⡀ #{reset}⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡐⠠⠡⢁⢂#{bold}#{orange}⠸⡸⡸⡸⡸⡘⡆⡇⡧⡀#{reset}⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⡂⡂⠅⠅⡂⡂⡂#{bold}#{orange}⠱⠱⠱⢱⢱⢱⢱⢱⢱⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠠⢀⢂⢂⠂⠅⠅⡂⡂⡂⠅⠅⠅⡂#{bold}#{orange}⢣⢣⢣⢣⠣⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠠⢁⢂⢂⠂⠌⠌⡐⡐⡐⠠⠡⠡⢁⠂⠌⠌#{bold}#{orange}⠪⡪⠂⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠨⢐⢐⢐⠨⠨⢐⢐⢐⠠⠡⠡⢁⠂⠌⠌⠌⡐⡀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠂⠂⠂⠌⠌⠐⠐⠐⠨⠨⠨⠐⠨⠨⠨⠐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + " + elsif id == 1006 + print " +⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⡐⠨⢐⢐⢐⠨⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡂⠅⡂⡂⡂⠌⠌⡐⡐⡐⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⢀⢐⠨⢐⠠⢁⢂⢂⠂⠅⠅⡂⡂⡂⠅⠅⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⡂⡂⠌⡐⠨⢐⢐⢐⠨⠨⢐⢐⢐⠠⠡⢁⠂⠅⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠐⠠⢁⠂⠅⡂⡂⡂⠌⠌⡐⡐⡐⠨⠨⢐⠨⠨⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠈⠐⠈⠐⠐⠐⠀⠁⠁⠂⠂⠂⠁⠁⠂⠈⠀⠀⠀⠀⠀⠀⠀ " + elsif id == 1009 || id == 804 + print " +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{gray} ⠀⢠⣰⢴⢦⣄⠀⠀⠀#{reset}⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡐⡐⡐#{gray}⡈⠳⡯⡯⡷⣝⡧⣠⢄⡀⠀⠀⠀⠀⠀#{reset}⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠠⠡#{gray}⢙⠽⠽⡳⣝⣗⡯⣯⢀⠀⠀⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠀⠀⠄⠄⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠#{gray}⢹⢮⡻⡮⣯⣻⠄⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠠⠨⠨⢐⢐⢐⢐⢐⠠⠡⢁⠂⠌⡐⠨⠨⠩#{gray}⠙⣽⣺⠺⠁⠀⠀⠀⠀#{reset}⠀⠀ +⠀⠀⠀⠀⠨⠨⠨⢐⢐⢐⢐⢐⠨⠨⢐⠨⢐⠠⠡⠡⠡⢁⠂⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠈⠌⠐⠐⠐⠐⠐⠨⠨⠐⠨⠐⠨⠨⠨⠨⠐⠀⠀⠀⠀⠀⠀⠀⠀ + + " + elsif id == 1072 || id == 1150 || id == 1153 || id == 1168 || id == 1180 || id == 1183 || id == 1186 || id == 1189 || id == 1198 || id == 1240 + print " + +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠠⢐⠀#{gray}⢮⢯⣗⣟⡦⣠⡀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠡⢁⠂⠌⠄#{gray}⠹⠞⢮⡻⣮⣻⣂⡀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠄⡂⠅⠅⡂⠌⠌⠌⠌⠌⡐#{gray}⡸⣗⣗⣗⣟⠆⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠨⢐⠠⠡⢁⠂⠅⠅⠅⠅⠅⡂⡂⡂⡑⠓#{gray}⠉⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠈⠐⠨⠨⠐#{blue}⣬#{reset}⠨⠨⠨⠨⢐⢐⢐⢐⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ +#{blue}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠁⢠⡄⠀⢜⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋⠠⣈⠂⡠⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ #{reset} + + " + elsif id == 1087 + print " + +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{gray}⡀⣤⢤⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢐⢐⢐⠐#{gray}⢽⣺⢽⢮⡻⣆⣄⣄⠀⠀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠀⠀⢐⢐⢐⢐⢐⠨⠠#{gray}⢹⠽⠽⣽⣺⡺⡮⣇⡀⠀⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠀⠠⠠⢐⢐⢐⢐⢐⠨⠨⢐⠨⢐⠈#{gray}⡾⡽⡽⡮⡯⣧⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠌⠌⠌⡐⡐⡐⡐⡐⠨⠨⢐⠨⢐⠠⠡⢉#{gray}⢫⢯⠻⠊⠀⠀⠀⠀⠀#{reset} +⠀⠀⠀⠀⠀⠡⠡⢁⢂⢂#{yellow}⢢⡒⡎#{reset}⠌⠌⡐⠨⢐⠨⠨⢐⢐⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠁⠂⠂#{yellow}⡂⡇⡇⡖#{reset}⠡⠁⠂⠅⠂⠌⠌⠐⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀#{yellow}⠀⡜⠌⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀#{reset}⠀ + + " + end +end + \ No newline at end of file diff --git a/src/wfetch.cr b/src/wfetch.cr new file mode 100644 index 0000000..0b5f92c --- /dev/null +++ b/src/wfetch.cr @@ -0,0 +1,93 @@ +require "http/client" +require "json" +require "toml" +require "./icon-list" +require "option_parser" + +module Wfetch + VERSION = "0.1.0" + orange = "\e[38;5;214m" + red = "\e[38;5;52m" + bold = "\033[1m" + reset = "\e[0m" + + puts "#{bold}#{orange}Wfetch KoffeeJava 2026#{reset}" + + debug = false + + OptionParser.parse do |parser| + parser.banner = "Usage: wfetch [arguments]" + parser.on("-i", "--icons", "Shows all icons") { + icon(1000) + icon(1003) + icon(1006) + icon(1009) + icon(1072) + icon(1087) + print "End" + exit(1) + } + parser.on("-v", "--verbose", "Gives additional details.") {debug = true} + 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 + + + + config = TOML.parse(File.read("/home/koffeejava/.local/share/Wfetch/config.toml")) + city = config["city"] + api_key = config["api"] + + response = HTTP::Client.get "http://api.weatherapi.com/v1/current.json?q=#{city}&key=#{api_key}" + + if response.status_code != 200 + puts "Error: status code #{response.status_code}" + exit + end + + data = JSON.parse(response.body.lines.join) + + if debug == true + puts data + end + + fftemp = data["current"]["feelslike_f"] + fctemp = data["current"]["feelslike_c"] + temp = data["current"]["temp_f"] + tempm = data["current"]["temp_c"] + desc = data["current"]["condition"]["text"] + pressin = data["current"]["pressure_in"] + pressmb = data["current"]["pressure_mb"] + cwind = data["current"]["wind_mph"] + mwind = data["current"]["wind_kph"] + humidity = data["current"]["humidity"] + vism = data["current"]["vis_miles"] + visk = data["current"]["vis_km"] + heatindex_f = data["current"]["heatindex_f"] + heatindex_c = data["current"]["heatindex_c"] + windchill_f = data["current"]["windchill_f"] + windchill_c = data["current"]["windchill_c"] + id = data["current"]["condition"]["code"] + + disp = TOML.parse(File.read("/home/koffeejava/.local/share/Wfetch/disp.toml")) + + + repeat = 1 + File.each_line("/home/koffeejava/.local/share/Wfetch/disp.toml") do |line| + if disp["#{repeat}"].to_s == "{icon}" + icon(id) + end + puts disp["#{repeat}"].to_s.gsub("{temp_f}", temp).gsub("{temp_c}", tempm).gsub("{feels_temp_f}", fftemp).gsub("{feels_temp_c}", fctemp).gsub("{wind_mph}", cwind).gsub("{wind_kph}", mwind).gsub("{humidity}", humidity).gsub("{pressure_in}", pressin).gsub("{description}", desc).gsub("{orange}", "\e[38;5;214m").gsub("{blue}", "\e[38;5;33m").gsub("{bold}", "\033[1m").gsub("{reset}", "\e[0m").gsub("{icon}", nil) + + repeat += 1 + end + +end