initial commit
This commit is contained in:
44
cmd/main.go
Normal file
44
cmd/main.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"aislegopher"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// usage: aisegopher <product_id>
|
||||
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Println("usage: aisegopher <product_id>")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
productId, err := strconv.Atoi(os.Args[1])
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Invalid product ID: ", os.Args[1], " error:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
priceHistory, err := aislegopher.GetPriceHistory(productId)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error getting price history: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Regular Prices:")
|
||||
|
||||
for _, dp := range priceHistory.RegularPrices {
|
||||
fmt.Println(dp.Date, dp.Price)
|
||||
}
|
||||
|
||||
if len(priceHistory.ThirdPartyPrices) > 0 {
|
||||
fmt.Println("Third Party Prices:")
|
||||
for _, dp := range priceHistory.ThirdPartyPrices {
|
||||
fmt.Println(dp.Date, dp.Price)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user