feat: implement comprehensive music service account management with full golangci-lint compliance

This commit completes the music service account management implementation
and resolves all golangci-lint issues across the codebase.

Music Service Account Management:
• Add/remove accounts for all major streaming services (Spotify, Pandora, Amazon Music, Deezer, iHeartRadio)
• Support for network music libraries (NAS/UPnP/DLNA servers)
• Generic account management with service-specific convenience methods
• Full CLI integration with 14 account management commands
• Comprehensive test coverage with mock HTTP servers
• Complete API documentation and usage examples

New CLI Commands:
• account list - List configured accounts
• account add/remove - Generic account management
• account add-spotify/remove-spotify - Spotify Premium
• account add-pandora/remove-pandora - Pandora Music Service
• account add-amazon/remove-amazon - Amazon Music
• account add-deezer/remove-deezer - Deezer Premium
• account add-iheart/remove-iheart - iHeartRadio
• account add-nas/remove-nas - Network music libraries

New API Methods:
• SetMusicServiceAccount() / RemoveMusicServiceAccount() - Generic methods
• AddSpotifyAccount() / RemoveSpotifyAccount() - Convenience methods
• AddPandoraAccount() / RemovePandoraAccount() - Convenience methods
• AddAmazonMusicAccount() / RemoveAmazonMusicAccount() - Convenience methods
• AddDeezerAccount() / RemoveDeezerAccount() - Convenience methods
• AddIHeartRadioAccount() / RemoveIHeartRadioAccount() - Convenience methods
• AddStoredMusicAccount() / RemoveStoredMusicAccount() - Network libraries

golangci-lint Fixes (36 issues resolved):
• errcheck (3): Fixed unchecked w.Write() returns in tests
• gocritic (3): Rewrote if-else chains to switch statements
• gocyclo (6): Reduced cyclomatic complexity via helper function extraction
• govet (12): Removed unused test data and field assignments
• revive (6): Added package comments and fixed unused parameters
• staticcheck (2): Replaced deprecated strings.Title usage
• thelper (6): Added t.Helper() calls to test helper functions
• unused (1): Removed unused createTestApp() function
• whitespace/wsl_v5 (7): Fixed whitespace and formatting issues

Code Quality Improvements:
• All functions now have complexity < 15 (down from max 28)
• Consistent error handling and validation patterns
• Better separation of concerns with extracted helper functions
• Zero external dependencies added for simple fixes
• Comprehensive documentation with usage examples
• Full backward compatibility maintained

Files Added:
• pkg/models/account.go - Account management models
• pkg/models/account_test.go - Account model tests
• pkg/client/account_test.go - Account client tests
• cmd/soundtouch-cli/cmd_account.go - Account CLI commands
• examples/account-management/ - Complete usage example
• Updated docs/CLI-REFERENCE.md with account management section

The implementation provides a complete, production-ready music service
account management system with full CLI and programmatic API support.
This commit is contained in:
Tobias Gesellchen
2026-02-02 17:44:26 +01:00
parent dd6b3941d4
commit 285f85efa2
26 changed files with 3524 additions and 394 deletions
+16
View File
@@ -1,3 +1,4 @@
// Package main demonstrates content selection functionality for Bose SoundTouch devices.
package main
import (
@@ -41,35 +42,41 @@ func main() {
func demonstrateContentSelection(c *client.Client) error {
// 1. Demonstrate LOCAL_INTERNET_RADIO with streamUrl format
fmt.Println("📻 Step 1: Demonstrating LOCAL_INTERNET_RADIO with streamUrl format...")
if err := demoLocalInternetRadioStreamUrl(c); err != nil {
return fmt.Errorf("failed LOCAL_INTERNET_RADIO demo: %w", err)
}
// Wait and show what's playing
time.Sleep(3 * time.Second)
if err := showNowPlaying(c); err != nil {
fmt.Printf("⚠️ Could not get now playing: %v\n", err)
}
// 2. Demonstrate LOCAL_INTERNET_RADIO with direct stream
fmt.Println("\n📻 Step 2: Demonstrating LOCAL_INTERNET_RADIO with direct stream...")
if err := demoLocalInternetRadioDirect(c); err != nil {
return fmt.Errorf("failed direct stream demo: %w", err)
}
// Wait and show what's playing
time.Sleep(3 * time.Second)
if err := showNowPlaying(c); err != nil {
fmt.Printf("⚠️ Could not get now playing: %v\n", err)
}
// 3. Demonstrate LOCAL_MUSIC selection
fmt.Println("\n💿 Step 3: Demonstrating LOCAL_MUSIC selection...")
if err := demoLocalMusic(c); err != nil {
fmt.Printf("⚠️ LOCAL_MUSIC demo failed (this requires SoundTouch App Media Server): %v\n", err)
} else {
// Wait and show what's playing
time.Sleep(3 * time.Second)
if err := showNowPlaying(c); err != nil {
fmt.Printf("⚠️ Could not get now playing: %v\n", err)
}
@@ -77,11 +84,13 @@ func demonstrateContentSelection(c *client.Client) error {
// 4. Demonstrate STORED_MUSIC selection
fmt.Println("\n💾 Step 4: Demonstrating STORED_MUSIC selection...")
if err := demoStoredMusic(c); err != nil {
fmt.Printf("⚠️ STORED_MUSIC demo failed (this requires UPnP/DLNA media server): %v\n", err)
} else {
// Wait and show what's playing
time.Sleep(3 * time.Second)
if err := showNowPlaying(c); err != nil {
fmt.Printf("⚠️ Could not get now playing: %v\n", err)
}
@@ -89,12 +98,14 @@ func demonstrateContentSelection(c *client.Client) error {
// 5. Demonstrate generic ContentItem selection
fmt.Println("\n🎯 Step 5: Demonstrating generic ContentItem selection...")
if err := demoGenericContentItem(c); err != nil {
return fmt.Errorf("failed generic ContentItem demo: %w", err)
}
// Wait and show what's playing
time.Sleep(3 * time.Second)
if err := showNowPlaying(c); err != nil {
fmt.Printf("⚠️ Could not get now playing: %v\n", err)
}
@@ -120,6 +131,7 @@ func demoLocalInternetRadioStreamUrl(c *client.Client) error {
}
fmt.Printf(" ✅ Successfully selected internet radio with streamUrl format\n")
return nil
}
@@ -139,6 +151,7 @@ func demoLocalInternetRadioDirect(c *client.Client) error {
}
fmt.Printf(" ✅ Successfully selected direct internet radio stream\n")
return nil
}
@@ -162,6 +175,7 @@ func demoLocalMusic(c *client.Client) error {
}
fmt.Printf(" ✅ Successfully selected local music content\n")
return nil
}
@@ -184,6 +198,7 @@ func demoStoredMusic(c *client.Client) error {
}
fmt.Printf(" ✅ Successfully selected stored music content\n")
return nil
}
@@ -211,6 +226,7 @@ func demoGenericContentItem(c *client.Client) error {
}
fmt.Printf(" ✅ Successfully selected content using ContentItem\n")
return nil
}