2023-01-07 07:40:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2023-01-08 00:03:43 +00:00
|
|
|
"log"
|
2023-01-07 07:40:39 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2023-01-08 05:34:31 +00:00
|
|
|
"gospt/internal/api"
|
2023-01-08 05:22:54 +00:00
|
|
|
"gospt/internal/auth"
|
|
|
|
"gospt/internal/config"
|
2023-01-08 05:26:06 +00:00
|
|
|
"gospt/internal/gctx"
|
2023-01-07 07:40:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
homeDir, _ := os.UserHomeDir()
|
|
|
|
configDir := filepath.Join(homeDir, ".config/gospt/")
|
|
|
|
config.LoadConfig(configDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var err error
|
2023-01-08 00:03:43 +00:00
|
|
|
log.New(os.Stdout, "LOG:", 0)
|
2023-01-08 05:26:06 +00:00
|
|
|
ctx := gctx.NewContext(context.Background())
|
2023-01-08 05:22:54 +00:00
|
|
|
client, err := auth.GetClient(ctx)
|
2023-01-07 07:40:39 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
2023-01-08 07:57:33 +00:00
|
|
|
currentUser, err := client.CurrentUser(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
ctx.UserId = currentUser.ID
|
2023-01-08 05:34:31 +00:00
|
|
|
err = api.Run(ctx, client, os.Args[1:])
|
2023-01-07 07:40:39 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|