42 lines
770 B
Go
42 lines
770 B
Go
package main
|
|
|
|
import "surdeus.su/core/amo"
|
|
import "surdeus.su/core/cli/mtool"
|
|
import "surdeus.su/core/amo/companies"
|
|
import "encoding/json"
|
|
import "log"
|
|
import "os"
|
|
|
|
var updateComs =
|
|
mtool.T("update-coms").Func(func(flags *mtool.Flags){
|
|
var (
|
|
secretPath string
|
|
)
|
|
|
|
flags.StringVar(
|
|
&secretPath,
|
|
"secret",
|
|
"",
|
|
"path to JSON file with AMO CRM secrets",
|
|
"AMO_SECRET",
|
|
)
|
|
|
|
flags.Parse()
|
|
|
|
client, err := amo.NewClient(secretPath)
|
|
if err != nil {
|
|
log.Fatalf("NewAmoClient(...): %s\n", err)
|
|
}
|
|
|
|
cs := []companies.Company{}
|
|
dec := json.NewDecoder(os.Stdin)
|
|
err = dec.Decode(&cs)
|
|
if err != nil {
|
|
log.Fatalf("json.Decode(...): %s\n", err)
|
|
}
|
|
|
|
err = client.UpdateCompanies(cs)
|
|
if err != nil {
|
|
log.Fatalf("client.UpdateCompanies(...): %s\n", err)
|
|
}
|
|
})
|