Skip to content

Commit 7ac17b6

Browse files
author
unknown
committed
Merge branch 'release/v1.6'
2 parents 362695c + 90b9c3d commit 7ac17b6

103 files changed

Lines changed: 2409 additions & 50 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![Downloads](https://img.shields.io/nuget/dt/console-weather?style=for-the-badge&logo=nuget)
66
![License](https://img.shields.io/github/license/pazurkota/console-weather?style=for-the-badge)
77

8-
Console Weather project is a simple application project to check weather in console. This project uses the [Weather API](https://www.weatherapi.com/) for best weather forecast
8+
Console Weather project is a simple application project to check weather in console. You can get it on project official [NuGet](https://www.nuget.org/packages/console-weather/) page
99

1010

1111

@@ -20,14 +20,13 @@ Console Weather project is a simple application project to check weather in cons
2020
- Show Weather Alerts
2121
- Show Weather Forecast for a next day
2222
- Show Air Quality
23-
24-
23+
- Show Weather Icons
2524

2625
## Installation
2726

2827
If you installed [.NET 7.0 or newer](https://dotnet.microsoft.com/en-us/download), just simply paste this command into console:
2928
```console
30-
$ dotnet tool install --global console-weather --version 1.2.1
29+
$ dotnet tool install --global console-weather --version 1.6.0
3130
```
3231

3332
If you want to update, just type:
@@ -54,44 +53,67 @@ $ weather -u Si
5453

5554
# To get air quality data, type:
5655
$ weather -a
56+
57+
# To show weather without icons, type:
58+
$ weather --dont-show-icons
5759
```
5860

5961

6062
## Demo
6163
```console
62-
$ weather -c "Kansas City" --no-alerts
64+
$ weather -c "Kansas City" --no-alerts -f -a
65+
66+
:::
67+
.: === .:.
68+
.===. === .==-
69+
==- ==-
70+
.:. .::---::. ...
71+
.====: .-===========- ..............
72+
:- -===--------====:.... ....
73+
===------------=-... ...
74+
..... :===-------::::..... ...
75+
====- :==------:......... ...
76+
.===---:... ...
77+
-===-:... .....
78+
:-=: :=-:... ....
79+
===:. .... ...
80+
... ...
81+
... ...
82+
... ....
83+
.... ....
84+
.......................................
6385

6486
CURRENT WEATHER:
65-
Current weather for London in United Kingdom is Partly cloudy
66-
The temperature is 19,0°C, but feels like 19,0°C
87+
Current weather for Kansas City in United States of America is Partly cloudy
88+
The temperature is 22,2°C, but feels like 24,6°C
6789

68-
Current Wind Speed: 22,0 kph (NE)
69-
Current Air Pressure: 1024,0 mbar
70-
Current Visibility: 10,0 kilometers
90+
Current Wind Speed: 11,2 kph (E)
91+
Current Air Pressure: 1011,0 mbar
92+
Current Visibility: 14,0 kilometers
7193
Current Precipitation: 0,0 mm
72-
Current Humidity: 46%
73-
Current Cloud Cover: 50%
74-
Current UV Index: 5,0 (Moderate)
94+
Current Humidity: 71%
95+
Current Cloud Cover: 25%
96+
Current UV Index: 4,0 (Moderate)
7597

7698
FORECAST:
77-
Tomorrow it will be Cloudy
78-
Temperature Range: 7,9°C - 17,7°C (average: 13,2)°C
79-
Maximum Wind Speed: 19,8 kph
99+
Tomorrow it will be Partly cloudy
100+
Temperature Range: 13,8°C - 26,2°C (average: 19,9°C)
101+
Maximum Wind Speed: 13,7 kph
80102
Average Visibility: 10,0 kilometers
81103
Maximum Precipitation: 0,0 mm
82-
UV Index: 3,0 (Moderate)
104+
UV Index: 5,0 (Moderate)
83105
Chance of rain/snow: 0% / 0%
84106

85107
AIR QUALITY:
86-
Carbon Monoxide: 205,30 ug/m3
87-
Nitrogen Dioxide: 4,40 ug/m3
88-
Ozone: 113,0 ug/m3
89-
Sulphur Dioxide: 3,30 ug/m3
90-
Fine Particles Matter: 4,40 ug/m3
91-
Coarse Particles Matter: 7,5 ug/m3
108+
Carbon Monoxide: 337,10 ug/m3
109+
Nitrogen Dioxide: 13,0 ug/m3
110+
Ozone: 37,90 ug/m3
111+
Sulphur Dioxide: 2,30 ug/m3
112+
Fine Particles Matter: 13,10 ug/m3
113+
Coarse Particles Matter: 13,5 ug/m3
92114
US Epa Index: 1 (Good)
93115

94-
Last Update: 2023-05-20 14:45
116+
Last Update: 2023-06-08 09:00
95117
```
96118
## Contributing
97119

@@ -104,7 +126,14 @@ Please look also at the [Code Of Conduct](https://github.com/pazurkota/console-w
104126

105127
## Acknowledgements
106128

107-
- [NuGet Page](https://www.nuget.org/packages/console-weather/)
129+
#### Used frameworks:
130+
- [Newtonsoft.Json](https://www.newtonsoft.com/json)
131+
- [RestSharp](https://restsharp.dev)
132+
- [System.CommandLine](https://learn.microsoft.com/en-us/dotnet/standard/commandline/)
133+
134+
#### API and Icons:
135+
- [Weather API](https://www.weatherapi.com/)
136+
- [ASCII Converter](https://ascii-generator.site)
108137

109138

110139
## Lessons Learned
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using console_weather.API;
2+
3+
namespace console_weather.Icons;
4+
5+
public static class IconsHandler {
6+
private static readonly string DayIconsPath = @"Icons\Day\";
7+
private static readonly string NightIconsPath = @"Icons\Night\";
8+
9+
private static readonly int IsDay = ApiData.ParseData().Current.IsDay;
10+
private static readonly int ConditionCole = ApiData.ParseData().Current.Condition.ConditionCode;
11+
12+
public static string GetIcon() {
13+
var icon = IsDay == 1 ? GetDayIcon() : GetNightIcon();
14+
var iconContent = File.ReadAllText(icon);
15+
16+
return iconContent;
17+
}
18+
19+
private static string GetDayIcon() {
20+
var dayIcons = Directory.GetFiles(DayIconsPath);
21+
var conditionCode = GetConditionCode()[ConditionCole];
22+
var icon = dayIcons.FirstOrDefault(icon => icon.Contains(conditionCode));
23+
24+
return icon;
25+
}
26+
27+
private static string GetNightIcon() {
28+
var nightIcons = Directory.GetFiles(NightIconsPath);
29+
var conditionCode = GetConditionCode()[ConditionCole];
30+
var icon = nightIcons.FirstOrDefault(icon => icon.Contains(conditionCode));
31+
32+
return icon;
33+
}
34+
35+
// Dictionary of condition codes and their corresponding icon names
36+
// More info: https://www.weatherapi.com/docs/weather_conditions.json
37+
private static Dictionary<int, string> GetConditionCode() {
38+
Dictionary<int, string> dictionary = new Dictionary<int, string>() {
39+
{1000, "113"},
40+
{1003, "116"},
41+
{1006, "119"},
42+
{1009, "122"},
43+
{1030, "143"},
44+
{1063, "176"},
45+
{1066, "179"},
46+
{1069, "182"},
47+
{1072, "185"},
48+
{1087, "200"},
49+
{1114, "227"},
50+
{1117, "230"},
51+
{1135, "248"},
52+
{1147, "260"},
53+
{1150, "263"},
54+
{1153, "266"},
55+
{1168, "281"},
56+
{1171, "284"},
57+
{1180, "293"},
58+
{1183, "296"},
59+
{1186, "299"},
60+
{1189, "302"},
61+
{1192, "305"},
62+
{1195, "308"},
63+
{1198, "311"},
64+
{1201, "314"},
65+
{1204, "317"},
66+
{1207, "320"},
67+
{1210, "323"},
68+
{1213, "326"},
69+
{1216, "329"},
70+
{1219, "332"},
71+
{1222, "335"},
72+
{1225, "338"},
73+
{1237, "350"},
74+
{1240, "353"},
75+
{1243, "356"},
76+
{1246, "359"},
77+
{1249, "362"},
78+
{1252, "365"},
79+
{1255, "368"},
80+
{1258, "371"},
81+
{1261, "374"},
82+
{1264, "377"},
83+
{1273, "386"},
84+
{1276, "389"},
85+
{1279, "392"},
86+
{1282, "395"},
87+
};
88+
89+
return dictionary;
90+
}
91+
}

console-weather/Icons/day/113.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.--.
2+
:-- .==: --:
3+
.===. .--. .===.
4+
-:. .:-
5+
.=-: :-======-: :-=.
6+
.-===. .-============-. :===-.
7+
.. -===----------===: ..
8+
:===------------===:
9+
:----. ===--------------=== .----:
10+
:----. ===--------------=== .----:
11+
:===------------===:
12+
.. -===----------===: ..
13+
.-===. .-============-. .===-.
14+
.=-: :-======-: :-=.
15+
-:. .:-
16+
.===. .--. .===.
17+
:-- .==: --:
18+
.==.

console-weather/Icons/day/116.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:::
2+
.: === .:.
3+
.===. === .==-
4+
==- ==-
5+
.:. .::---::. ...
6+
.====: .-===========- ..............
7+
:- -===--------====:.... ....
8+
===------------=-... ...
9+
..... :===-------::::..... ...
10+
====- :==------:......... ...
11+
.===---:... ...
12+
-===-:... .....
13+
:-=: :=-:... ....
14+
===:. .... ...
15+
... ...
16+
... ...
17+
... ....
18+
.... ....
19+
.......................................

console-weather/Icons/day/119.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
...
2+
..............
3+
..... ....
4+
... ....
5+
....... ...
6+
......... ...
7+
.... ...
8+
... .....
9+
.... ....
10+
.... ...
11+
... ..
12+
.. ...
13+
... ...
14+
... ....
15+
.......................................

console-weather/Icons/day/122.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
..:::::..
2+
:-====----===-:.
3+
:==-::. ..:-==-.
4+
.-=-:. .-==:
5+
.:---==-. .-==:
6+
:-==--:::-. .-==
7+
.-==:. :==.
8+
==-. -===-.
9+
.:-==: ..-==-
10+
-==-::. .==-
11+
-=-. :==.
12+
.==: :==.
13+
==-. :==-
14+
.==-:.................................:-==-
15+
:-====================================:.
16+
.................................

console-weather/Icons/day/143.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
...
2+
..............
3+
..... ....
4+
... ....
5+
....... ...
6+
......... ...
7+
.... ...
8+
... .....
9+
.... ....
10+
.... ...
11+
... ..
12+
.. ...
13+
... ...
14+
... ....
15+
.......................................
16+
17+
18+
19+
20+
..................................

console-weather/Icons/day/176.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:::
2+
.: === .:.
3+
.===. === .==-
4+
==- ==-
5+
.:. .::---::. ..:::::..
6+
.====: .-===========- :-===----====-:
7+
:- -===--------====:-==-:.. ..:-==:
8+
===------------====-. :-==.
9+
..... :===-----------====-. .-==.
10+
====- :==-------===--::--. .==-
11+
.===----==-:. -==
12+
-===--==-. -===-.
13+
:-=: :======. .:-==-
14+
===:. .-==-:. :==-
15+
.==-. -==
16+
:==. -==
17+
.==: .:==:
18+
:==-:.................................:-==:
19+
.-====================================-:
20+
..................................
21+
22+
:==: :==:
23+
:==: :==:
24+
:==: :==:
25+
:==: :==:
26+
::. ::.

console-weather/Icons/day/179.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:::
2+
.: === .:.
3+
.===. === .==-
4+
==- ==-
5+
.:. .::---::. ..:::::..
6+
.====: .-===========- :-===----====-:
7+
:- -===--------====:-==-:.. ..:-==:
8+
===------------====-. :-==.
9+
..... :===-----------====-. .-==.
10+
====- :==-------===--::--. .==-
11+
.===----==-:. -==
12+
-===--==-. -===-.
13+
:-=: :======. .:-==-
14+
===:. .-==-:. :==-
15+
.==-. -==
16+
:==. -==
17+
.==: .:==:
18+
:==-:.................................:-==:
19+
.-====================================-:
20+
..................................
21+
22+
.. .
23+
.....
24+
.........
25+
.....

0 commit comments

Comments
 (0)