garth more done

This commit is contained in:
2025-08-29 07:08:35 -07:00
parent fd0924e85e
commit 6b17d41a7a
13 changed files with 340 additions and 443 deletions

View File

@@ -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)