Add function generate_output() to avoid repetition of code when generating the result output from a show command.
show_hostgroups, show_usergroup and show alarms use this function now.