How can I get a user's associated Apple ID from the command line?
AppleIDs aren't specifically 'associated' with any given local user account - if there is an AppleID signed in on the Mac you might try using mas:

https://github.com/argon/mas

Specifically the command mas account should show you the currently logged-in AppleID.