-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (37 loc) · 1.14 KB
/
main.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
"os"
"Solarflare/ecobee"
)
var (
//Set your kingpin help flags for app var
app = kingpin.New("solarflare", "Program for Ecobee Thermostats").Author("Kyle Wooten")
ecobeeApiKey = app.Flag("apikey", "Ecobee API Key (Example Format: 4ok2o45k4o25k4o25kok) ").Envar("ECOBEE_APIKEY").Required().String()
firstRun = app.Flag("first", "Enables Ecobee Pin functions to authenticate your application on the first run.").Envar("ECOBEE_FIRST").Default("false").Bool()
)
var (
Version = "0.0.2"
GitCommit = "HEAD"
BuildStamp = "UNKNOWN"
FullVersion = Version + "+" + GitCommit + "-" + BuildStamp
)
func init() {
app.Version(FullVersion)
}
func main() {
/// Parse kingpin app flags for --help option
kingpin.MustParse(app.Parse(os.Args[1:]))
/// Only used when setting up the program for the first time in https://www.ecobee.com/consumerportal
/// to get the bearer token
if *firstRun {
Code, err := ecobee.Get_ecobee_pin(*ecobeeApiKey)
if err != nil {
panic(err)
}
err = ecobee.GetToken(Code, *ecobeeApiKey)
if err != nil {
panic(err)
}
}
}