-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp - doc - Prepare the TWC weather forecast info
--- We need to make room for the new temperature querying system that uses TWC. --- Type: imp Breaking: False Doc Required: True Part: 1/1
- Loading branch information
Showing
3 changed files
with
114 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
public/Nitrocid.Addons/Nitrocid.Extras.Forecast/Forecast/Commands/WeatherOld.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// Nitrocid KS Copyright (C) 2018-2024 Aptivi | ||
// | ||
// This file is part of Nitrocid KS | ||
// | ||
// Nitrocid KS is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Nitrocid KS is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY, without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using System.Linq; | ||
using Nettify.Weather; | ||
using Nitrocid.ConsoleBase.Colors; | ||
using Nitrocid.ConsoleBase.Writers; | ||
using Terminaux.Writer.ConsoleWriters; | ||
using Nitrocid.Languages; | ||
using Nitrocid.Shell.ShellBase.Commands; | ||
using Nitrocid.ConsoleBase.Inputs; | ||
|
||
namespace Nitrocid.Extras.Forecast.Forecast.Commands | ||
{ | ||
/// <summary> | ||
/// Shows weather information for a specified city | ||
/// </summary> | ||
/// <remarks> | ||
/// We credit OpenWeatherMap for their decent free API service for weather information for the cities around the world. It requires that you have your own API key for OpenWeatherMap. Don't worry, Nitrocid KS only accesses free features; all you have to do is make an account and generate your own API key. | ||
/// <br></br> | ||
/// This command lets you get current weather information for a specified city by city ID as recommended by OpenWeatherMap. If you want a list, use the switch indicated below. | ||
/// <br></br> | ||
/// <list type="table"> | ||
/// <listheader> | ||
/// <term>Switches</term> | ||
/// <description>Description</description> | ||
/// </listheader> | ||
/// <item> | ||
/// <term>-list</term> | ||
/// <description>Lists the available cities</description> | ||
/// </item> | ||
/// </list> | ||
/// <br></br> | ||
/// </remarks> | ||
class WeatherOldCommand : BaseCommand, ICommand | ||
{ | ||
|
||
public override int Execute(CommandParameters parameters, ref string variableValue) | ||
{ | ||
var ListMode = false; | ||
if (parameters.SwitchesList.Contains("-list")) | ||
ListMode = true; | ||
if (ListMode) | ||
{ | ||
var Cities = WeatherForecast.ListAllCities(); | ||
ListWriterColor.WriteList(Cities); | ||
} | ||
else | ||
{ | ||
string APIKey = Forecast.ApiKey; | ||
if (parameters.ArgumentsList.Length > 1) | ||
{ | ||
APIKey = parameters.ArgumentsList[1]; | ||
} | ||
else if (string.IsNullOrEmpty(APIKey)) | ||
{ | ||
TextWriterColor.Write(Translate.DoTranslation("You can get your own API key at https://home.openweathermap.org/api_keys.")); | ||
TextWriters.Write(Translate.DoTranslation("Enter your API key:") + " ", false, KernelColorType.Input); | ||
APIKey = InputTools.ReadLineNoInput(); | ||
Forecast.ApiKey = APIKey; | ||
} | ||
Forecast.PrintWeatherInfo(parameters.ArgumentsList[0], APIKey); | ||
} | ||
return 0; | ||
} | ||
|
||
public override void HelpHelper() | ||
{ | ||
TextWriterColor.Write(Translate.DoTranslation("You can either consult the below link for the list of cities with their IDs, or, pass \"-list\" to this command.")); | ||
TextWriterColor.Write("http://bulk.openweathermap.org/sample/city.list.json.gz"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters