go-pagerduty icon indicating copy to clipboard operation
go-pagerduty copied to clipboard

command: selectable output formats (JSON/YAML)

Open jsleeio opened this issue 1 year ago • 2 comments

Give the user a choice of YAML or JSON output for all commands that emit either format. I have left the default format as YAML.

I have also removed the Entry: 123 output lines which seemed like they were intended for debugging. I'm happy to be wrong here and restore them (for YAML output only, as it's clearly incompatible with JSON).

As-implemented, this will break scripted usage for the below commands that default to JSON. Given the breakdown of YAML vs. JSON usage here I think this is the least-bad option.

The other options I considered were:

  • default to JSON (break most usage)
  • default to nothing and require a flag (break everyone's usage)
  • have a third 'auto' state that maintained the current behaviour (breaks rule of least surprise)

Commands emitting JSON (with this change they will emit YAML):

$ grep -l json.Marshal command/*go
command/addon_update.go
command/analytics_incident_show.go
command/analytics_service_show.go
command/analytics_team_show.go

Commands emitting YAML:

$ grep -l 'yaml\.Marshal' command/*go
command/addon_list.go
command/addon_show.go
command/escalation_policy_list.go
command/escalation_policy_show.go
command/event_orchestration_list.go
command/event_orchestration_show.go
command/incident_list.go
command/maintenance_window_list.go
command/maintenance_window_show.go
command/oncall_list.go
command/schedule_list.go
command/service_list.go
command/service_rule_list.go
command/service_rule_show.go
command/service_show.go
command/standard_list.go
command/standard_multi_resources_scores_list.go
command/standard_resource_scores_list.go
command/team_list.go
command/team_show.go
command/user_list.go
command/vendor_list.go
command/vendor_show.go

jsleeio avatar Feb 08 '24 09:02 jsleeio

@ChuckCrawford any thoughts on this?

jsleeio avatar Mar 13 '24 03:03 jsleeio

@ChuckCrawford are you interested in this PR at all? if so I can rebase, retest, etc

jsleeio avatar Sep 19 '24 03:09 jsleeio