client: Factor out scan command