A man has appeared in court after he was allegedly attacked with a hammer in Sydney's Inner West.