mirror of
https://github.com/sstent/go-garminconnect.git
synced 2026-01-25 16:42:32 +00:00
garth more done
This commit is contained in:
@@ -10,11 +10,28 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/sstent/go-garminconnect/internal/api"
|
||||
"github.com/sstent/go-garminconnect/internal/auth/garth"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "garmin-cli",
|
||||
Short: "CLI for interacting with Garmin Connect API",
|
||||
}
|
||||
|
||||
var authCmd = &cobra.Command{
|
||||
Use: "auth",
|
||||
Short: "Authentication commands",
|
||||
}
|
||||
|
||||
var loginCmd = &cobra.Command{
|
||||
Use: "login",
|
||||
Short: "Authenticate with Garmin Connect",
|
||||
Run: loginHandler,
|
||||
}
|
||||
|
||||
func loginHandler(cmd *cobra.Command, args []string) {
|
||||
// Try to load from .env if environment variables not set
|
||||
if os.Getenv("GARMIN_USERNAME") == "" || os.Getenv("GARMIN_PASSWORD") == "" {
|
||||
if err := godotenv.Load(); err != nil {
|
||||
@@ -91,6 +108,18 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Setup command structure
|
||||
authCmd.AddCommand(loginCmd)
|
||||
rootCmd.AddCommand(authCmd)
|
||||
|
||||
// Execute CLI
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// getCredentials prompts for username and password
|
||||
func getCredentials() (string, string) {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
Reference in New Issue
Block a user