Inital commit
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -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
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/docs/
|
||||||
|
/lib/
|
||||||
|
/bin/
|
||||||
|
/.shards/
|
||||||
|
*.dwarf
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 koffeejava <aidenspurger572@gmail.com>
|
||||||
|
|
||||||
|
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.
|
||||||
27
README.md
Normal file
27
README.md
Normal file
@@ -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 (<https://github.com/your-github-user/wfetch/fork>)
|
||||||
|
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
|
||||||
6
shard.lock
Normal file
6
shard.lock
Normal file
@@ -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
|
||||||
|
|
||||||
18
shard.yml
Normal file
18
shard.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
name: wfetch
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- koffeejava <aidenspurger572@gmail.com>
|
||||||
|
|
||||||
|
targets:
|
||||||
|
wfetch:
|
||||||
|
main: src/wfetch.cr
|
||||||
|
|
||||||
|
crystal: '>= 1.19.1'
|
||||||
|
|
||||||
|
license: MIT
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
toml:
|
||||||
|
github: crystal-community/toml.cr
|
||||||
|
branch: master
|
||||||
2
spec/spec_helper.cr
Normal file
2
spec/spec_helper.cr
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
require "spec"
|
||||||
|
require "../src/wfetch"
|
||||||
9
spec/wfetch_spec.cr
Normal file
9
spec/wfetch_spec.cr
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
require "./spec_helper"
|
||||||
|
|
||||||
|
describe Wfetch do
|
||||||
|
# TODO: Write tests
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
false.should eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
78
src/icon-list.cr
Normal file
78
src/icon-list.cr
Normal file
@@ -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
|
||||||
|
|
||||||
93
src/wfetch.cr
Normal file
93
src/wfetch.cr
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user