-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Taylor Price <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/obot-platform/tools/weather | ||
|
||
go 1.24.0 | ||
|
||
require github.com/icodealot/noaa v0.0.2 |
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,2 @@ | ||
github.com/icodealot/noaa v0.0.2 h1:nL21mFSxJUBog7/0/vakIfA109T2A8/JpowzEzL9O+w= | ||
github.com/icodealot/noaa v0.0.2/go.mod h1:vPMSrP4zBvlbWC34qtUR5w64dCp0xSRjkLy9/Ky81go= |
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,46 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/icodealot/noaa" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
log.Fatal("usage: weather <command>") | ||
} | ||
|
||
command := os.Args[1] | ||
|
||
latitude := os.Getenv("LATITUDE") | ||
if latitude == "" { | ||
log.Fatal("required latitude parameter not set") | ||
} | ||
longitude := os.Getenv("LONGITUDE") | ||
if longitude == "" { | ||
log.Fatal("required longitude parameter not set") | ||
} | ||
|
||
switch command { | ||
case "getWeeklyForecast": | ||
forecast, err := noaa.Forecast(latitude, longitude) | ||
if err != nil { | ||
log.Fatalf("error getting the forecast: %v", err) | ||
return | ||
} | ||
for _, period := range forecast.Periods { | ||
fmt.Printf("%-20s ---> %.0f%s\n", period.Name, period.Temperature, period.TemperatureUnit) | ||
} | ||
case "getHourlyForecast": | ||
forecast, err := noaa.HourlyForecast(latitude, longitude) | ||
if err != nil { | ||
log.Fatalf("error getting the forecast: %v", err) | ||
} | ||
for _, period := range forecast.Periods { | ||
fmt.Printf("%-20s ---> %.0f%s\n", period.StartTime, period.Temperature, period.TemperatureUnit) | ||
} | ||
} | ||
|
||
} |
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,21 @@ | ||
--- | ||
Name: Weather | ||
Description: Tools for getting the weather forecast | ||
Metadata: bundle: true | ||
Share Tools: Get Weekly Forecast, Get Hourly Forecast | ||
|
||
--- | ||
Name: Get Weekly Forecast | ||
Description: Gets the weekly forecast for a given latitude and longitude | ||
Param: latitude: The latitude to look up the forecast for | ||
Param: longitude: The longitude to look up the forecast for | ||
|
||
#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool getWeeklyForecast | ||
|
||
--- | ||
Name: Get Hourly Forecast | ||
Description: Gets the hourly forecast for a given latitude and longitude | ||
Param: latitude: The latitude to look up the forecast for | ||
Param: longitude: The longitude to look up the forecast for | ||
|
||
#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool getHourlyForecast |